Calculate the filteredEmojis on first change. (#4987)
* if it is a initial render then calculate the filteredemojis * set filteredEmojis based on the previous result * removed timeout variable Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
9f680ef33c
commit
7a166bd1d6
1 changed files with 10 additions and 3 deletions
|
|
@ -179,6 +179,7 @@ export default class EmojiPicker extends PureComponent {
|
|||
const nextState = {
|
||||
searchTerm: rawText,
|
||||
};
|
||||
const prevSearchTerm = this.state.searchTerm;
|
||||
this.setState(nextState);
|
||||
|
||||
if (!searchTerm) {
|
||||
|
|
@ -187,13 +188,19 @@ export default class EmojiPicker extends PureComponent {
|
|||
}
|
||||
|
||||
clearTimeout(this.searchTermTimeout);
|
||||
const timeout = searchTerm ? 100 : 0;
|
||||
this.searchTermTimeout = setTimeout(() => {
|
||||
if (prevSearchTerm === '') {
|
||||
const filteredEmojis = this.searchEmojis(searchTerm);
|
||||
this.setState({
|
||||
filteredEmojis,
|
||||
});
|
||||
}, timeout);
|
||||
} else {
|
||||
this.searchTermTimeout = setTimeout(() => {
|
||||
const filteredEmojis = this.searchEmojis(searchTerm);
|
||||
this.setState({
|
||||
filteredEmojis,
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
cancelSearch = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue