From 00d92b3e62b1db0fc012b352f557ad3a02c53244 Mon Sep 17 00:00:00 2001 From: VH Date: Sat, 20 May 2023 10:49:51 +0700 Subject: [PATCH 1/2] Fix mentions results does not close when we change focus to first character --- src/pages/home/report/ReportActionCompose.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index b234348384f9..a7da0435d644 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -280,6 +280,10 @@ class ReportActionCompose extends React.Component { onSelectionChange(e) { LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity)); this.setState({selection: e.nativeEvent.selection}); + if (!this.state.value || this.state.selection.end < 1) { + this.resetSuggestions(); + return; + } this.calculateEmojiSuggestion(); this.calculateMentionSuggestion(); } @@ -459,10 +463,6 @@ class ReportActionCompose extends React.Component { * Calculates and cares about the content of an Emoji Suggester */ calculateEmojiSuggestion() { - if (!this.state.value) { - this.resetSuggestions(); - return; - } if (this.state.shouldBlockEmojiCalc) { this.setState({shouldBlockEmojiCalc: false}); return; @@ -493,10 +493,6 @@ class ReportActionCompose extends React.Component { } calculateMentionSuggestion() { - if (this.state.selection.end < 1) { - return; - } - const valueAfterTheCursor = this.state.value.substring(this.state.selection.end); const indexOfFirstWhitespaceCharOrEmojiAfterTheCursor = valueAfterTheCursor.search(CONST.REGEX.NEW_LINE_OR_WHITE_SPACE_OR_EMOJI); From 85b7eb2e5e4db7588539496a23271a62d262778e Mon Sep 17 00:00:00 2001 From: VH Date: Sat, 20 May 2023 11:05:47 +0700 Subject: [PATCH 2/2] Use event params instead of state to get update to date value --- src/pages/home/report/ReportActionCompose.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index a7da0435d644..2fb615eb999e 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -280,7 +280,7 @@ class ReportActionCompose extends React.Component { onSelectionChange(e) { LayoutAnimation.configureNext(LayoutAnimation.create(50, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity)); this.setState({selection: e.nativeEvent.selection}); - if (!this.state.value || this.state.selection.end < 1) { + if (!this.state.value || e.nativeEvent.selection.end < 1) { this.resetSuggestions(); return; }