Răsfoiți Sursa

Don't submit comment on clicking cancel

James Allen 9 ani în urmă
părinte
comite
fb91219661

+ 2 - 2
services/web/app/views/project/editor/review-panel.pug

@@ -340,10 +340,10 @@ script(type='text/ng-template', id='addCommentEntryTemplate')
 						ng-keypress="handleCommentKeyPress($event);"
 						ng-keypress="handleCommentKeyPress($event);"
 						placeholder=translate("add_your_comment_here")
 						placeholder=translate("add_your_comment_here")
 						focus-on="comment:new:open"
 						focus-on="comment:new:open"
-						ng-blur="submitNewComment()"
+						ng-blur="submitNewComment($event)"
 					)
 					)
 				.rp-entry-actions
 				.rp-entry-actions
-					button.rp-entry-button(
+					button.rp-entry-button.rp-entry-button-cancel(
 						ng-click="cancelNewComment();"
 						ng-click="cancelNewComment();"
 					) 
 					) 
 						i.fa.fa-times
 						i.fa.fa-times

+ 4 - 1
services/web/public/coffee/ide/review-panel/directives/addCommentEntry.coffee

@@ -31,7 +31,10 @@ define [
 					if scope.state.content.length > 0 
 					if scope.state.content.length > 0 
 						scope.submitNewComment()
 						scope.submitNewComment()
 
 
-			scope.submitNewComment = () ->
+			scope.submitNewComment = (event) ->
+				# If this is from a blur event from clicking on cancel, ignore it.
+				if event? and event.type == "blur" and $(event.relatedTarget).hasClass("rp-entry-button-cancel")
+					return true
 				scope.onSubmit { content: scope.state.content }
 				scope.onSubmit { content: scope.state.content }
 				scope.state.isAdding = false
 				scope.state.isAdding = false
 				scope.state.content = ""
 				scope.state.content = ""