[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
This commit is contained in:
Devin Binnie 2024-02-12 11:05:11 -05:00 committed by GitHub
parent c723bf345a
commit cf11adff98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -259,6 +259,7 @@ export default class SuggestionBox extends React.PureComponent {
handleEmitClearSuggestions = (delay = 0) => { handleEmitClearSuggestions = (delay = 0) => {
setTimeout(() => { setTimeout(() => {
this.clear(); this.clear();
this.handlePretextChanged('');
}, delay); }, delay);
}; };
@ -465,6 +466,7 @@ export default class SuggestionBox extends React.PureComponent {
} }
this.clear(); this.clear();
this.handlePretextChanged('');
if (openCommandInModal) { if (openCommandInModal) {
const appProvider = this.props.providers.find((p) => p.openAppsModalFromCommand); const appProvider = this.props.providers.find((p) => p.openAppsModalFromCommand);
@ -556,7 +558,6 @@ export default class SuggestionBox extends React.PureComponent {
selection: '', selection: '',
suggestionBoxAlgn: undefined, suggestionBoxAlgn: undefined,
}); });
this.handlePretextChanged('');
} }
}; };

View File

@ -293,4 +293,12 @@ describe('components/SuggestionBox', () => {
instance.componentDidMount(); instance.componentDidMount();
expect(instance.handlePretextChanged).toHaveBeenCalledTimes(1); 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();
});
}); });