Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arrow focus shortcut modal local state (v2.0) #18599

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/ArrowKeyFocusManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ArrowKeyFocusManager extends Component {
}

this.props.onFocusedIndexChanged(newFocusedIndex);
}, arrowUpConfig.descriptionKey, arrowUpConfig.modifiers, true, false, 1, true, [this.props.shouldExcludeTextAreaNodes && 'TEXTAREA']);
}, arrowUpConfig.descriptionKey, arrowUpConfig.modifiers, true, false, 0, true, [this.props.shouldExcludeTextAreaNodes && 'TEXTAREA']);

this.unsubscribeArrowDownKey = KeyboardShortcut.subscribe(arrowDownConfig.shortcutKey, () => {
if (this.props.maxIndex < 0) {
Expand All @@ -70,7 +70,7 @@ class ArrowKeyFocusManager extends Component {
}

this.props.onFocusedIndexChanged(newFocusedIndex);
}, arrowDownConfig.descriptionKey, arrowDownConfig.modifiers, true, false, 1, true, [this.props.shouldExcludeTextAreaNodes && 'TEXTAREA']);
}, arrowDownConfig.descriptionKey, arrowDownConfig.modifiers, true, false, 0, true, [this.props.shouldExcludeTextAreaNodes && 'TEXTAREA']);
}

componentWillUnmount() {
Expand Down
1 change: 0 additions & 1 deletion src/components/ButtonWithMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class ButtonWithMenu extends PureComponent {
text={selectedItem.text}
onPress={event => this.props.onPress(event, this.props.options[0].value)}
pressOnEnter
enterKeyEventListenerPriority={1}
/>
)}
{this.props.options.length > 1 && (
Expand Down
5 changes: 4 additions & 1 deletion src/components/KeyboardShortcutsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ export default compose(
withWindowDimensions,
withLocalize,
withOnyx({
isShortcutsModalOpen: {key: ONYXKEYS.IS_SHORTCUTS_MODAL_OPEN},
isShortcutsModalOpen: {
key: ONYXKEYS.IS_SHORTCUTS_MODAL_OPEN,
initWithStoredValues: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we want to init with the store value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of NAB but I would still like to know why we changed this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, ok that works for me. It's definitely not necessary for the keyboard shortcuts modal to persist it's open state between refreshes.

},
}),
)(KeyboardShortcutsModal);
3 changes: 1 addition & 2 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ 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 @@ -360,7 +359,7 @@ class BaseOptionsSelector extends Component {
text={defaultConfirmButtonText}
onPress={this.props.onConfirmSelection}
pressOnEnter
enterKeyEventListenerPriority={2}
enterKeyEventListenerPriority={1}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lowered this from 2 to 1 because now the priority for the enter key is 0 correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing that is the case. Do you think we should just leave as 2?

This change came from this PR: #18578

/>
)}
{this.props.footerContent}
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/KeyboardShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let isShortcutsModalOpen;
Onyx.connect({
key: ONYXKEYS.IS_SHORTCUTS_MODAL_OPEN,
callback: flag => isShortcutsModalOpen = flag,
initWithStoredValues: false,
});

/**
Expand Down
1 change: 0 additions & 1 deletion src/pages/iou/steps/MoneyRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ class MoneyRequestAmountPage extends React.Component {
pressOnEnter
isDisabled={!this.state.amount.length || parseFloat(this.state.amount) < 0.01}
text={this.props.buttonText}
enterKeyEventListenerPriority={1}
/>
</View>
</>
Expand Down