diff --git a/services/web/app/views/project/editor/review-panel.pug b/services/web/app/views/project/editor/review-panel.pug index e9bbad0c28..f5ba226a09 100644 --- a/services/web/app/views/project/editor/review-panel.pug +++ b/services/web/app/views/project/editor/review-panel.pug @@ -477,7 +477,6 @@ 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($event)" ) .rp-entry-actions button.rp-entry-button.rp-entry-button-cancel( diff --git a/services/web/frontend/js/ide/review-panel/directives/addCommentEntry.js b/services/web/frontend/js/ide/review-panel/directives/addCommentEntry.js index a10ff05754..198af8c50d 100644 --- a/services/web/frontend/js/ide/review-panel/directives/addCommentEntry.js +++ b/services/web/frontend/js/ide/review-panel/directives/addCommentEntry.js @@ -1,17 +1,5 @@ -/* eslint-disable - max-len, - no-return-assign, - no-undef, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ -define(['base'], App => +define(['base'], App => { + let content = '' App.directive('addCommentEntry', () => ({ restrict: 'E', templateUrl: 'addCommentEntryTemplate', @@ -23,48 +11,41 @@ define(['base'], App => link(scope, element, attrs) { scope.state = { isAdding: false, - content: '' + content: content } scope.$on('comment:start_adding', () => scope.startNewComment()) + scope.$on('$destroy', function() { + content = scope.state.content + }) scope.startNewComment = function() { scope.state.isAdding = true scope.onStartNew() - return setTimeout(() => scope.$broadcast('comment:new:open')) + setTimeout(() => scope.$broadcast('comment:new:open')) } scope.cancelNewComment = function() { scope.state.isAdding = false - return scope.onCancel() + scope.state.content = '' + scope.onCancel() } scope.handleCommentKeyPress = function(ev) { if (ev.keyCode === 13 && !ev.shiftKey && !ev.ctrlKey && !ev.metaKey) { ev.preventDefault() if (scope.state.content.length > 0) { - return scope.submitNewComment() + scope.submitNewComment() } } } - return (scope.submitNewComment = function(event) { - // If this is from a blur event from clicking on cancel, ignore it. - if (event != null && event.type === 'blur') { - if ( - // Includes relatedTarget workaround for Firefox - $(event.relatedTarget).hasClass('rp-entry-button-cancel') || - $(event.originalEvent.explicitOriginalTarget).hasClass( - 'rp-entry-button-cancel' - ) - ) { - return true - } - } - + scope.submitNewComment = function(event) { scope.onSubmit({ content: scope.state.content }) + content = scope.state.content scope.state.isAdding = false - return (scope.state.content = '') - }) + scope.state.content = '' + } } - }))) + })) +})