diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 062c4cfc5d60..628cb5323565 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -48,7 +48,6 @@ import MentionSuggestions from '../../../components/MentionSuggestions'; import withKeyboardState, {keyboardStatePropTypes} from '../../../components/withKeyboardState'; import ArrowKeyFocusManager from '../../../components/ArrowKeyFocusManager'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; -import KeyboardShortcut from '../../../libs/KeyboardShortcut'; import * as ComposerUtils from '../../../libs/ComposerUtils'; import * as ComposerActions from '../../../libs/actions/Composer'; import * as Welcome from '../../../libs/actions/Welcome'; @@ -231,24 +230,6 @@ class ReportActionCompose extends React.Component { this.focus(false); }); - const shortcutConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE; - this.unsubscribeEscapeKey = KeyboardShortcut.subscribe( - shortcutConfig.shortcutKey, - () => { - const suggestionsExist = this.state.suggestedEmojis.length > 0 || this.state.suggestedMentions.length > 0; - - if (!this.state.isFocused || this.comment.length === 0 || suggestionsExist) { - return; - } - - this.updateComment('', true); - }, - shortcutConfig.descriptionKey, - shortcutConfig.modifiers, - true, - true, - ); - this.setMaxLines(); this.updateComment(this.comment); @@ -293,10 +274,6 @@ class ReportActionCompose extends React.Component { componentWillUnmount() { ReportActionComposeFocusManager.clear(); - - if (this.unsubscribeEscapeKey) { - this.unsubscribeEscapeKey(); - } } onSelectionChange(e) { @@ -765,9 +742,13 @@ class ReportActionCompose extends React.Component { } return; } - if (e.key === CONST.KEYBOARD_SHORTCUTS.ESCAPE.shortcutKey && suggestionsExist) { + if (e.key === CONST.KEYBOARD_SHORTCUTS.ESCAPE.shortcutKey) { e.preventDefault(); - this.resetSuggestions(); + if (suggestionsExist) { + this.resetSuggestions(); + } else if (this.comment.length > 0) { + this.updateComment('', true); + } return; } diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 797c95c66165..1718f51bbf33 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -252,7 +252,7 @@ class ReportActionItemMessageEdit extends React.Component { if (e.key === CONST.KEYBOARD_SHORTCUTS.ENTER.shortcutKey && !e.shiftKey) { e.preventDefault(); this.publishDraft(); - } else if (e.key === 'Escape') { + } else if (e.key === CONST.KEYBOARD_SHORTCUTS.ESCAPE.shortcutKey) { e.preventDefault(); this.deleteDraft(); }