Skip to content

Commit

Permalink
Add enter shortcut for KeyboardShortcutsModal so that you can close i…
Browse files Browse the repository at this point in the history
…t by pressing enter
  • Loading branch information
azimgd committed May 2, 2023
1 parent eed5677 commit fce62f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/KeyboardShortcutsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ class KeyboardShortcutsModal extends React.Component {
KeyboardShortcutsActions.showKeyboardShortcutModal();
}, openShortcutModalConfig.descriptionKey, openShortcutModalConfig.modifiers, true);

const closeShortcutModalConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE;
this.unsubscribeEscapeModal = KeyboardShortcut.subscribe(closeShortcutModalConfig.shortcutKey, () => {
const closeShortcutEscapeModalConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE;
this.unsubscribeEscapeModal = KeyboardShortcut.subscribe(closeShortcutEscapeModalConfig.shortcutKey, () => {
ModalActions.close();
KeyboardShortcutsActions.hideKeyboardShortcutModal();
}, closeShortcutModalConfig.descriptionKey, closeShortcutModalConfig.modifiers, true, true);
}, closeShortcutEscapeModalConfig.descriptionKey, closeShortcutEscapeModalConfig.modifiers, true, true);

const closeShortcutEnterModalConfig = CONST.KEYBOARD_SHORTCUTS.ENTER;
this.unsubscribeEscapeModal = KeyboardShortcut.subscribe(closeShortcutEnterModalConfig.shortcutKey, () => {
ModalActions.close();
KeyboardShortcutsActions.hideKeyboardShortcutModal();
}, closeShortcutEnterModalConfig.descriptionKey, closeShortcutEnterModalConfig.modifiers, true, () => !this.props.isShortcutsModalOpen, 0);
}

componentWillUnmount() {
Expand Down
3 changes: 2 additions & 1 deletion src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class BaseOptionsSelector extends Component {
enterConfig.modifiers,
true,
() => !this.state.allOptions[this.state.focusedIndex],
1,
);

const CTRLEnterConfig = CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER;
Expand Down Expand Up @@ -359,7 +360,7 @@ class BaseOptionsSelector extends Component {
text={defaultConfirmButtonText}
onPress={this.props.onConfirmSelection}
pressOnEnter
enterKeyEventListenerPriority={1}
enterKeyEventListenerPriority={2}
/>
)}
{this.props.footerContent}
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/steps/MoneyRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ class MoneyRequestAmountPage extends React.Component {
pressOnEnter
isDisabled={!this.state.amount.length || parseFloat(this.state.amount) < 0.01}
text={this.props.buttonText}
enterKeyEventListenerPriority={2}
/>
</View>
</>
Expand Down

0 comments on commit fce62f8

Please sign in to comment.