-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10194 from rushatgabhane/delay-focus-for-android-…
…only OptionsSelector - delay input focus on android only
- Loading branch information
Showing
10 changed files
with
182 additions
and
138 deletions.
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