better fix for uri bar text input handling
This commit is contained in:
parent
d7635dc7ee
commit
2d91c83628
1 changed files with 3 additions and 18 deletions
|
@ -46,16 +46,10 @@ class UriBar extends React.PureComponent {
|
||||||
const { currentRoute: prevRoute } = this.props;
|
const { currentRoute: prevRoute } = this.props;
|
||||||
|
|
||||||
if (Constants.DRAWER_ROUTE_SEARCH === currentRoute && currentRoute !== prevRoute) {
|
if (Constants.DRAWER_ROUTE_SEARCH === currentRoute && currentRoute !== prevRoute) {
|
||||||
this.setState({ currentValue: query, inputText: query }, () => this.setCaretPosition());
|
this.setState({ currentValue: query, inputText: query });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange = evt => {
|
|
||||||
if (evt.nativeEvent && evt.nativeEvent.text) {
|
|
||||||
this.setCaretPosition();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
handleChangeText = text => {
|
handleChangeText = text => {
|
||||||
const newValue = text || '';
|
const newValue = text || '';
|
||||||
clearTimeout(this.state.changeTextTimeout);
|
clearTimeout(this.state.changeTextTimeout);
|
||||||
|
@ -130,20 +124,11 @@ class UriBar extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
setSelection() {
|
setSelection() {
|
||||||
if (this.textInput) {
|
if (this.textInput && !this.state.focused) {
|
||||||
this.textInput.setNativeProps({ selection: { start: 0, end: 0 } });
|
this.textInput.setNativeProps({ selection: { start: 0, end: 0 } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setCaretPosition() {
|
|
||||||
if (this.textInput) {
|
|
||||||
const text = this.textInput.props.value;
|
|
||||||
if (text && text.length > 0) {
|
|
||||||
this.textInput.setNativeProps({ selection: { start: text.length, end: text.length } });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmitEditing = () => {
|
handleSubmitEditing = () => {
|
||||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
||||||
if (this.state.inputText) {
|
if (this.state.inputText) {
|
||||||
|
@ -194,7 +179,7 @@ class UriBar extends React.PureComponent {
|
||||||
value,
|
value,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if (this.state.currentValue === null) {
|
if (this.state.currentValue === null) {
|
||||||
this.setState({ currentValue: value }, () => this.setCaretPosition());
|
this.setState({ currentValue: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = [
|
let style = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue