fix multiple text entries when typing with Shift+Letter on Android (#2634)
This commit is contained in:
parent
771e5cd53b
commit
5bcf8f7576
5 changed files with 31 additions and 37 deletions
|
|
@ -191,14 +191,12 @@ export default class ChannelAddMembers extends PureComponent {
|
|||
};
|
||||
|
||||
onSearch = (text) => {
|
||||
const term = text.toLowerCase();
|
||||
|
||||
if (term) {
|
||||
this.setState({term});
|
||||
if (text) {
|
||||
this.setState({term: text});
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
this.searchProfiles(term);
|
||||
this.searchProfiles(text);
|
||||
}, General.SEARCH_TIMEOUT_MILLISECONDS);
|
||||
} else {
|
||||
this.clearSearch();
|
||||
|
|
@ -264,7 +262,7 @@ export default class ChannelAddMembers extends PureComponent {
|
|||
const options = {not_in_channel_id: currentChannelId, team_id: currentTeamId};
|
||||
this.setState({loading: true});
|
||||
|
||||
actions.searchProfiles(term, options).then(({data}) => {
|
||||
actions.searchProfiles(term.toLowerCase(), options).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -197,14 +197,12 @@ export default class ChannelMembers extends PureComponent {
|
|||
};
|
||||
|
||||
onSearch = (text) => {
|
||||
const term = text.toLowerCase();
|
||||
|
||||
if (term) {
|
||||
this.setState({term});
|
||||
if (text) {
|
||||
this.setState({term: text});
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
this.searchProfiles(term);
|
||||
this.searchProfiles(text);
|
||||
}, General.SEARCH_TIMEOUT_MILLISECONDS);
|
||||
} else {
|
||||
this.clearSearch();
|
||||
|
|
@ -287,7 +285,7 @@ export default class ChannelMembers extends PureComponent {
|
|||
const options = {in_channel_id: currentChannelId};
|
||||
this.setState({loading: true});
|
||||
|
||||
actions.searchProfiles(term, options).then(({data}) => {
|
||||
actions.searchProfiles(term.toLowerCase(), options).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -132,8 +132,9 @@ export default class MoreChannels extends PureComponent {
|
|||
};
|
||||
|
||||
filterChannels = (channels, term) => {
|
||||
const lowerCasedTerm = term.toLowerCase();
|
||||
return channels.filter((c) => {
|
||||
return (c.name.toLowerCase().includes(term) || c.display_name.toLowerCase().includes(term));
|
||||
return (c.name.toLowerCase().includes(lowerCasedTerm) || c.display_name.toLowerCase().includes(lowerCasedTerm));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -289,18 +290,17 @@ export default class MoreChannels extends PureComponent {
|
|||
|
||||
searchChannels = (text) => {
|
||||
const {actions, channels, currentTeamId} = this.props;
|
||||
const term = text.toLowerCase();
|
||||
|
||||
if (term) {
|
||||
const filtered = this.filterChannels(channels, term);
|
||||
if (text) {
|
||||
const filtered = this.filterChannels(channels, text);
|
||||
this.setState({
|
||||
channels: filtered,
|
||||
term,
|
||||
term: text,
|
||||
});
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
actions.searchChannels(currentTeamId, term);
|
||||
actions.searchChannels(currentTeamId, text.toLowerCase());
|
||||
}, General.SEARCH_TIMEOUT_MILLISECONDS);
|
||||
} else {
|
||||
this.cancelSearch();
|
||||
|
|
|
|||
|
|
@ -246,14 +246,12 @@ export default class MoreDirectMessages extends PureComponent {
|
|||
};
|
||||
|
||||
onSearch = (text) => {
|
||||
const term = text.toLowerCase();
|
||||
|
||||
if (term) {
|
||||
this.setState({term});
|
||||
if (text) {
|
||||
this.setState({term: text});
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
this.searchProfiles(term);
|
||||
this.searchProfiles(text);
|
||||
}, General.SEARCH_TIMEOUT_MILLISECONDS);
|
||||
} else {
|
||||
this.clearSearch();
|
||||
|
|
@ -261,15 +259,16 @@ export default class MoreDirectMessages extends PureComponent {
|
|||
};
|
||||
|
||||
searchProfiles = (term) => {
|
||||
const lowerCasedTerm = term.toLowerCase();
|
||||
const {actions, currentTeamId, restrictDirectMessage} = this.props;
|
||||
this.setState({loading: true});
|
||||
|
||||
if (restrictDirectMessage) {
|
||||
actions.searchProfiles(term).then(({data}) => {
|
||||
actions.searchProfiles(lowerCasedTerm).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
} else {
|
||||
actions.searchProfiles(term, {team_id: currentTeamId}).then(({data}) => {
|
||||
actions.searchProfiles(lowerCasedTerm, {team_id: currentTeamId}).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,23 +178,21 @@ export default class SelectorScreen extends PureComponent {
|
|||
};
|
||||
|
||||
onSearch = (text) => {
|
||||
const term = text.toLowerCase();
|
||||
|
||||
if (term) {
|
||||
if (text) {
|
||||
const {dataSource, data} = this.props;
|
||||
this.setState({term});
|
||||
this.setState({term: text});
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(() => {
|
||||
if (!dataSource) {
|
||||
this.setState({searchResults: filterSearchData(null, data, term)});
|
||||
this.setState({searchResults: filterSearchData(null, data, text)});
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataSource === ViewTypes.DATA_SOURCE_USERS) {
|
||||
this.searchProfiles(term);
|
||||
this.searchProfiles(text);
|
||||
} else if (dataSource === ViewTypes.DATA_SOURCE_CHANNELS) {
|
||||
this.searchChannels(term);
|
||||
this.searchChannels(text);
|
||||
}
|
||||
}, General.SEARCH_TIMEOUT_MILLISECONDS);
|
||||
} else {
|
||||
|
|
@ -205,7 +203,7 @@ export default class SelectorScreen extends PureComponent {
|
|||
searchChannels = (term) => {
|
||||
const {actions, currentTeamId} = this.props;
|
||||
|
||||
actions.searchChannels(currentTeamId, term).then(({data}) => {
|
||||
actions.searchChannels(currentTeamId, term.toLowerCase()).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
};
|
||||
|
|
@ -214,7 +212,7 @@ export default class SelectorScreen extends PureComponent {
|
|||
const {actions} = this.props;
|
||||
this.setState({loading: true});
|
||||
|
||||
actions.searchProfiles(term).then(({data}) => {
|
||||
actions.searchProfiles(term.toLowerCase()).then(({data}) => {
|
||||
this.setState({searchResults: data, loading: false});
|
||||
});
|
||||
};
|
||||
|
|
@ -380,11 +378,12 @@ const filterSearchData = memoizeResult((dataSource, data, term) => {
|
|||
return [];
|
||||
}
|
||||
|
||||
const lowerCasedTerm = term.toLowerCase();
|
||||
if (dataSource === ViewTypes.DATA_SOURCE_USERS) {
|
||||
return filterProfilesMatchingTerm(data, term);
|
||||
return filterProfilesMatchingTerm(data, lowerCasedTerm);
|
||||
} else if (dataSource === ViewTypes.DATA_SOURCE_CHANNELS) {
|
||||
return filterChannelsMatchingTerm(data, term);
|
||||
return filterChannelsMatchingTerm(data, lowerCasedTerm);
|
||||
}
|
||||
|
||||
return data.filter((option) => option.text && option.text.toLowerCase().startsWith(term));
|
||||
return data.filter((option) => option.text && option.text.toLowerCase().startsWith(lowerCasedTerm));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue