Skip to content

Commit

Permalink
[MM-56478] Only clear the suggestion pretext when the suggestion is c…
Browse files Browse the repository at this point in the history
…ompleted and not when the list is cleared (mattermost#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
  • Loading branch information
devinbinnie authored Feb 12, 2024
1 parent c723bf3 commit cf11adf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export default class SuggestionBox extends React.PureComponent {
handleEmitClearSuggestions = (delay = 0) => {
setTimeout(() => {
this.clear();
this.handlePretextChanged('');
}, delay);
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -556,7 +558,6 @@ export default class SuggestionBox extends React.PureComponent {
selection: '',
suggestionBoxAlgn: undefined,
});
this.handlePretextChanged('');
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<SuggestionBox {...baseProps}/>);
const instance = wrapper.instance();
instance.handlePretextChanged = jest.fn();
instance.clear();
expect(instance.handlePretextChanged).not.toHaveBeenCalled();
});
});

0 comments on commit cf11adf

Please sign in to comment.