From b4b23d4d46da6138baaf14c55876d6f55d93e775 Mon Sep 17 00:00:00 2001 From: Stephen Kiers Date: Mon, 12 Feb 2018 09:52:02 -0700 Subject: [PATCH] ICU-639- Fixes bug with Samsung keyboard (#1427) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- app/components/search_bar/search_bar.android.js | 12 ++++++++++-- .../channel_add_members/channel_add_members.js | 4 ++-- app/screens/channel_members/channel_members.js | 4 ++-- app/screens/more_channels/more_channels.js | 6 +++++- app/screens/more_dms/more_dms.js | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/components/search_bar/search_bar.android.js b/app/components/search_bar/search_bar.android.js index 633d5925819..0c7ab352c61 100644 --- a/app/components/search_bar/search_bar.android.js +++ b/app/components/search_bar/search_bar.android.js @@ -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 { { - 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(); diff --git a/app/screens/channel_members/channel_members.js b/app/screens/channel_members/channel_members.js index 38069007240..befd2cdacb2 100644 --- a/app/screens/channel_members/channel_members.js +++ b/app/screens/channel_members/channel_members.js @@ -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(); diff --git a/app/screens/more_channels/more_channels.js b/app/screens/more_channels/more_channels.js index 36c333afa85..2ba8028bc8b 100644 --- a/app/screens/more_channels/more_channels.js +++ b/app/screens/more_channels/more_channels.js @@ -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(() => { diff --git a/app/screens/more_dms/more_dms.js b/app/screens/more_dms/more_dms.js index f71ad0d46d1..80701c9fb6c 100644 --- a/app/screens/more_dms/more_dms.js +++ b/app/screens/more_dms/more_dms.js @@ -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();