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

Revert "OptionsSelector - Migrate setNativeProps to state" #11240

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Changes from all 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
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