From 9c8aa6939748d94f477fccda418cf5508b767998 Mon Sep 17 00:00:00 2001 From: Jayesh Mangwani Date: Tue, 30 May 2023 20:39:02 +0530 Subject: [PATCH 1/3] fix: prevent enter key press on BaseOptionsSelector when screen is not focused --- src/components/OptionsSelector/BaseOptionsSelector.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 312f5d386b61..e182d1bb67ef 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -9,11 +9,13 @@ import OptionsList from '../OptionsList'; import CONST from '../../CONST'; import styles from '../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import withNavigationFocus from '../withNavigationFocus'; import TextInput from '../TextInput'; import ArrowKeyFocusManager from '../ArrowKeyFocusManager'; import KeyboardShortcut from '../../libs/KeyboardShortcut'; import {propTypes as optionsSelectorPropTypes, defaultProps as optionsSelectorDefaultProps} from './optionsSelectorPropTypes'; import setSelection from '../../libs/setSelection'; +import compose from '../../libs/compose'; const propTypes = { /** Whether we should wait before focusing the TextInput, useful when using transitions on Android */ @@ -57,7 +59,7 @@ class BaseOptionsSelector extends Component { enterConfig.shortcutKey, () => { const focusedOption = this.state.allOptions[this.state.focusedIndex]; - if (!focusedOption) { + if (!focusedOption || !this.props.isFocused ) { return; } if (this.props.canSelectMultipleOptions) { @@ -375,4 +377,4 @@ class BaseOptionsSelector extends Component { BaseOptionsSelector.defaultProps = defaultProps; BaseOptionsSelector.propTypes = propTypes; -export default withLocalize(BaseOptionsSelector); +export default compose(withLocalize, withNavigationFocus)(BaseOptionsSelector); From cd90969ffb76a16c2b0181fcd40442e4e3d1a548 Mon Sep 17 00:00:00 2001 From: Jayesh Mangwani Date: Tue, 30 May 2023 21:31:58 +0530 Subject: [PATCH 2/3] fixed prettier error --- src/components/OptionsSelector/BaseOptionsSelector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index e182d1bb67ef..1ab21628c6a8 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -59,7 +59,7 @@ class BaseOptionsSelector extends Component { enterConfig.shortcutKey, () => { const focusedOption = this.state.allOptions[this.state.focusedIndex]; - if (!focusedOption || !this.props.isFocused ) { + if (!focusedOption || !this.props.isFocused) { return; } if (this.props.canSelectMultipleOptions) { From 9b496809a90eae2557fda5fe6606d671a5c29636 Mon Sep 17 00:00:00 2001 From: Jayesh Mangwani Date: Wed, 31 May 2023 10:11:14 +0530 Subject: [PATCH 3/3] fix: added withNavigationFocusPropTypes to BaseOptionsSelector --- src/components/OptionsSelector/BaseOptionsSelector.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/OptionsSelector/BaseOptionsSelector.js b/src/components/OptionsSelector/BaseOptionsSelector.js index 1ab21628c6a8..df15ad71febc 100755 --- a/src/components/OptionsSelector/BaseOptionsSelector.js +++ b/src/components/OptionsSelector/BaseOptionsSelector.js @@ -9,7 +9,7 @@ import OptionsList from '../OptionsList'; import CONST from '../../CONST'; import styles from '../../styles/styles'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import withNavigationFocus from '../withNavigationFocus'; +import withNavigationFocus, {withNavigationFocusPropTypes} from '../withNavigationFocus'; import TextInput from '../TextInput'; import ArrowKeyFocusManager from '../ArrowKeyFocusManager'; import KeyboardShortcut from '../../libs/KeyboardShortcut'; @@ -26,6 +26,7 @@ const propTypes = { ...optionsSelectorPropTypes, ...withLocalizePropTypes, + ...withNavigationFocusPropTypes, }; const defaultProps = {