diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 6af89e25dbb6..aaca67ddb539 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -47,6 +47,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '../../../componen import withDrawerState from '../../../components/withDrawerState'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; import withKeyboardState, {keyboardStatePropTypes} from '../../../components/withKeyboardState'; +import KeyboardShortcut from '../../../libs/KeyboardShortcut'; const propTypes = { /** Beta features list */ @@ -168,6 +169,16 @@ class ReportActionCompose extends React.Component { this.focus(false); }); + + const shortcutConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE; + this.unsubscribeEscapeKey = KeyboardShortcut.subscribe(shortcutConfig.shortcutKey, () => { + if (!this.state.isFocused || this.comment.length === 0) { + return; + } + + this.updateComment(''); + }, shortcutConfig.descriptionKey, shortcutConfig.modifiers, true); + this.setMaxLines(); this.updateComment(this.comment); } @@ -201,6 +212,10 @@ class ReportActionCompose extends React.Component { componentWillUnmount() { ReportActionComposeFocusManager.clear(); + + if (this.unsubscribeEscapeKey) { + this.unsubscribeEscapeKey(); + } } onSelectionChange(e) {