-
Notifications
You must be signed in to change notification settings - Fork 3k
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
OptionsSelector - delay input focus on android only #10194
Merged
Luke9389
merged 6 commits into
Expensify:main
from
rushatgabhane:delay-focus-for-android-only
Aug 5, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
400874b
make shouldDelayFocus android only
rushatgabhane eab4c30
rm unnecessary podfile changes
rushatgabhane 76c92a6
formatting
rushatgabhane 12e180d
Merge branch 'Expensify:main' into delay-focus-for-android-only
rushatgabhane 463dc8d
Merge branch 'main' into delay-focus-for-android-only
rushatgabhane 47e4cd6
Merge branch 'main' into delay-focus-for-android-only
rushatgabhane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, {forwardRef} from 'react'; | ||
import BaseOptionsSelector from './BaseOptionsSelector'; | ||
import {propTypes, defaultProps} from './optionsSelectorPropTypes'; | ||
|
||
const OptionsSelector = forwardRef((props, ref) => ( | ||
<BaseOptionsSelector | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
shouldDelayFocus | ||
/> | ||
)); | ||
|
||
OptionsSelector.propTypes = propTypes; | ||
OptionsSelector.defaultProps = defaultProps; | ||
OptionsSelector.displayName = 'OptionsSelector'; | ||
|
||
export default OptionsSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, {forwardRef} from 'react'; | ||
import BaseOptionsSelector from './BaseOptionsSelector'; | ||
import {propTypes, defaultProps} from './optionsSelectorPropTypes'; | ||
|
||
const OptionsSelector = forwardRef((props, ref) => ( | ||
<BaseOptionsSelector | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
/> | ||
)); | ||
|
||
OptionsSelector.propTypes = propTypes; | ||
OptionsSelector.defaultProps = defaultProps; | ||
OptionsSelector.displayName = 'OptionsSelector'; | ||
|
||
export default OptionsSelector; |
125 changes: 125 additions & 0 deletions
125
src/components/OptionsSelector/optionsSelectorPropTypes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import PropTypes from 'prop-types'; | ||
import optionPropTypes from '../optionPropTypes'; | ||
import {withLocalizePropTypes} from '../withLocalize'; | ||
import styles from '../../styles/styles'; | ||
|
||
const propTypes = { | ||
/** Callback to fire when a row is tapped */ | ||
onSelectRow: PropTypes.func, | ||
|
||
/** Sections for the section list */ | ||
sections: PropTypes.arrayOf(PropTypes.shape({ | ||
/** Title of the section */ | ||
title: PropTypes.string, | ||
|
||
/** The initial index of this section given the total number of options in each section's data array */ | ||
indexOffset: PropTypes.number, | ||
|
||
/** Array of options */ | ||
data: PropTypes.arrayOf(optionPropTypes), | ||
|
||
/** Whether this section should show or not */ | ||
shouldShow: PropTypes.bool, | ||
|
||
/** Whether this section items disabled for selection */ | ||
isDisabled: PropTypes.bool, | ||
})).isRequired, | ||
|
||
/** Value in the search input field */ | ||
value: PropTypes.string.isRequired, | ||
|
||
/** Callback fired when text changes */ | ||
onChangeText: PropTypes.func.isRequired, | ||
|
||
/** Label to display for the text input */ | ||
textInputLabel: PropTypes.string, | ||
|
||
/** Optional placeholder text for the selector */ | ||
placeholderText: PropTypes.string, | ||
|
||
/** Options that have already been selected */ | ||
selectedOptions: PropTypes.arrayOf(optionPropTypes), | ||
|
||
/** Optional header message */ | ||
headerMessage: PropTypes.string, | ||
|
||
/** Whether we can select multiple options */ | ||
canSelectMultipleOptions: PropTypes.bool, | ||
|
||
/** Whether any section headers should be visible */ | ||
hideSectionHeaders: PropTypes.bool, | ||
|
||
/** Whether to allow arrow key actions on the list */ | ||
disableArrowKeysActions: PropTypes.bool, | ||
|
||
/** Whether to disable interactivity of option rows */ | ||
isDisabled: PropTypes.bool, | ||
|
||
/** A flag to indicate whether to show additional optional states, such as pin and draft icons */ | ||
hideAdditionalOptionStates: PropTypes.bool, | ||
|
||
/** Force the text style to be the unread style on all rows */ | ||
forceTextUnreadStyle: PropTypes.bool, | ||
|
||
/** Whether to show the title tooltip */ | ||
showTitleTooltip: PropTypes.bool, | ||
|
||
/** Whether to focus the textinput after an option is selected */ | ||
shouldFocusOnSelectRow: PropTypes.bool, | ||
|
||
/** Whether to autofocus the search input on mount */ | ||
autoFocus: PropTypes.bool, | ||
|
||
/** Should a button be shown if a selection is made (only relevant if canSelectMultipleOptions is true) */ | ||
shouldShowConfirmButton: PropTypes.bool, | ||
|
||
/** Text to show in the confirm button (only visible if multiple options are selected) */ | ||
confirmButtonText: PropTypes.string, | ||
|
||
/** Function to execute if the confirm button is pressed */ | ||
onConfirmSelection: PropTypes.func, | ||
|
||
/** If true, the text input will be below the options in the selector, not above. */ | ||
shouldTextInputAppearBelowOptions: PropTypes.bool, | ||
|
||
/** If true, a message will display in the footer if the app is offline. */ | ||
shouldShowOfflineMessage: PropTypes.bool, | ||
|
||
/** Custom content to display in the footer instead of the default button. */ | ||
footerContent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]), | ||
|
||
/** Hover style for options in the OptionsList */ | ||
optionHoveredStyle: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), | ||
|
||
/** Whether to show options list */ | ||
shouldShowOptions: PropTypes.bool, | ||
|
||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
onSelectRow: () => {}, | ||
textInputLabel: '', | ||
placeholderText: '', | ||
selectedOptions: [], | ||
headerMessage: '', | ||
canSelectMultipleOptions: false, | ||
hideSectionHeaders: false, | ||
hideAdditionalOptionStates: false, | ||
forceTextUnreadStyle: false, | ||
showTitleTooltip: false, | ||
shouldFocusOnSelectRow: false, | ||
autoFocus: true, | ||
shouldShowConfirmButton: false, | ||
confirmButtonText: undefined, | ||
onConfirmSelection: () => {}, | ||
shouldTextInputAppearBelowOptions: false, | ||
shouldShowOfflineMessage: false, | ||
footerContent: undefined, | ||
optionHoveredStyle: styles.hoveredComponentBG, | ||
shouldShowOptions: true, | ||
disableArrowKeysActions: false, | ||
isDisabled: false, | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting this propType warning:
I think it's because this component isn't using
withLocalize
. Can you please fix it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for letting me know!
Fix is here - #10763