Don't submit comment on clicking cancel

This commit is contained in:
James Allen 2017-03-08 11:38:28 +00:00
parent a4464a330c
commit fb91219661
2 changed files with 6 additions and 3 deletions

View file

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

View file

@ -31,7 +31,10 @@ define [
if scope.state.content.length > 0
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.state.isAdding = false
scope.state.content = ""