Skip to content

Commit

Permalink
Merge pull request #11240 from Expensify/revert-11036-rm-setNativePro…
Browse files Browse the repository at this point in the history
…ps-optionsSelector
  • Loading branch information
thienlnam authored Sep 23, 2022
2 parents 3780e0f + a905f6e commit 72e6268
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ class BaseOptionsSelector extends Component {
this.state = {
allOptions,
focusedIndex: this.props.shouldTextInputAppearBelowOptions ? allOptions.length : 0,
selection: {
start: this.props.value.length,
end: this.props.value.length,
},
};
}

Expand Down Expand Up @@ -206,7 +202,7 @@ class BaseOptionsSelector extends Component {
selectRow(option, ref) {
if (this.props.shouldFocusOnSelectRow) {
// Input is permanently focused on native platforms, so we always highlight the text inside of it
this.setState({selection: {start: 0, end: this.props.value.length}});
this.textInput.setNativeProps({selection: {start: 0, end: this.props.value.length}});
if (this.relatedTarget && ref === findNodeHandle(this.relatedTarget)) {
this.textInput.focus();
}
Expand Down Expand Up @@ -236,7 +232,12 @@ class BaseOptionsSelector extends Component {
ref={el => this.textInput = el}
value={this.props.value}
label={this.props.textInputLabel}
onChangeText={this.props.onChangeText}
onChangeText={(text) => {
if (this.props.shouldFocusOnSelectRow) {
this.textInput.setNativeProps({selection: null});
}
this.props.onChangeText(text);
}}
placeholder={this.props.placeholderText || this.props.translate('optionsSelector.nameEmailOrPhoneNumber')}
onBlur={(e) => {
if (!this.props.shouldFocusOnSelectRow) {
Expand All @@ -246,8 +247,6 @@ class BaseOptionsSelector extends Component {
}}
selectTextOnFocus
blurOnSubmit={Boolean(this.state.allOptions.length)}
selection={this.state.selection}
onSelectionChange={e => this.setState({selection: e.nativeEvent.selection})}
/>
);
const optionsList = this.props.shouldShowOptions ? (
Expand Down

0 comments on commit 72e6268

Please sign in to comment.