ICU-639- Fixes bug with Samsung keyboard (#1427)

* Internalized value to local state so that there is less ‘delay’ and less surface area for bugs to happen

* removed toLowercase on comparison and fixed parent components instead

* Update more_channels.js
This commit is contained in:
Stephen Kiers 2018-02-12 09:52:02 -07:00 committed by Elias Nahum
parent a9a8017006
commit 42af38944e
No known key found for this signature in database
GPG key ID: E038DB71E0B61702
5 changed files with 21 additions and 9 deletions

View file

@ -66,9 +66,15 @@ export default class SearchBarAndroid extends PureComponent {
constructor(props) {
super(props);
this.state = {
value: props.value,
isFocused: false
};
}
componentWillReceiveProps(nextProps) {
if (this.state.value !== nextProps.value) {
this.setState({value: nextProps.value});
}
}
cancel = () => {
this.onCancelButtonPress();
@ -102,7 +108,9 @@ export default class SearchBarAndroid extends PureComponent {
};
onChangeText = (value) => {
this.props.onChangeText(value);
this.setState({value}, () => {
this.props.onChangeText(value);
});
};
onSelectionChange = (event) => {
@ -196,7 +204,7 @@ export default class SearchBarAndroid extends PureComponent {
<TextInput
ref='input'
blurOnSubmit={blurOnSubmit}
value={value}
value={this.state.value}
autoCapitalize={autoCapitalize}
autoCorrect={false}
returnKeyType={returnKeyType || 'search'}

View file

@ -205,7 +205,7 @@ class ChannelAddMembers extends PureComponent {
};
searchProfiles = (text) => {
const term = text.toLowerCase();
const term = text;
const {actions, currentChannel, currentTeam} = this.props;
if (term) {
@ -213,7 +213,7 @@ class ChannelAddMembers extends PureComponent {
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
actions.searchProfiles(term, {not_in_channel_id: currentChannel.id, team_id: currentTeam.id});
actions.searchProfiles(term.toLowerCase(), {not_in_channel_id: currentChannel.id, team_id: currentTeam.id});
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();

View file

@ -253,14 +253,14 @@ class ChannelMembers extends PureComponent {
};
searchProfiles = (text) => {
const term = text.toLowerCase();
const term = text;
if (term) {
this.setState({searching: true, term});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
this.props.actions.searchProfiles(term, {in_channel_id: this.props.currentChannel.id});
this.props.actions.searchProfiles(term.toLowerCase(), {in_channel_id: this.props.currentChannel.id});
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();

View file

@ -153,7 +153,11 @@ class MoreChannels extends PureComponent {
if (term) {
const channels = this.filterChannels(this.state.channels, term);
this.setState({channels, term, searching: true});
this.setState({
channels,
term: text,
searching: true
});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {

View file

@ -162,14 +162,14 @@ class MoreDirectMessages extends PureComponent {
};
onSearch = (text) => {
const term = text.toLowerCase();
const term = text;
if (term) {
this.setState({searching: true, term});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
this.searchProfiles(term);
this.searchProfiles(term.toLowerCase());
}, General.SEARCH_TIMEOUT_MILLISECONDS);
} else {
this.cancelSearch();