From cf11adff980496aba305753cdc9090db26916a8f Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:05:11 -0500 Subject: [PATCH] [MM-56478] Only clear the suggestion pretext when the suggestion is completed and not when the list is cleared (#26151) * [MM-56478] Only clear the suggestion pretext when the suggestion is completed and not when the list is cleared * Also clear pretext when unfocusing the box --- .../suggestion/suggestion_box/suggestion_box.jsx | 3 ++- .../suggestion/suggestion_box/suggestion_box.test.jsx | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.jsx b/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.jsx index 4f1b21a6b15..f0673089fd8 100644 --- a/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.jsx +++ b/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.jsx @@ -259,6 +259,7 @@ export default class SuggestionBox extends React.PureComponent { handleEmitClearSuggestions = (delay = 0) => { setTimeout(() => { this.clear(); + this.handlePretextChanged(''); }, delay); }; @@ -465,6 +466,7 @@ export default class SuggestionBox extends React.PureComponent { } this.clear(); + this.handlePretextChanged(''); if (openCommandInModal) { const appProvider = this.props.providers.find((p) => p.openAppsModalFromCommand); @@ -556,7 +558,6 @@ export default class SuggestionBox extends React.PureComponent { selection: '', suggestionBoxAlgn: undefined, }); - this.handlePretextChanged(''); } }; diff --git a/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.test.jsx b/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.test.jsx index a59467b5ccb..13a3bb7124d 100644 --- a/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.test.jsx +++ b/webapp/channels/src/components/suggestion/suggestion_box/suggestion_box.test.jsx @@ -293,4 +293,12 @@ describe('components/SuggestionBox', () => { instance.componentDidMount(); expect(instance.handlePretextChanged).toHaveBeenCalledTimes(1); }); + + test('should not clear pretext when clearing the suggestion list', () => { + const wrapper = shallow(); + const instance = wrapper.instance(); + instance.handlePretextChanged = jest.fn(); + instance.clear(); + expect(instance.handlePretextChanged).not.toHaveBeenCalled(); + }); });