diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx index 1c1633ff4a72f..b48f6f45ce4b8 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_list/components/alerts_list.tsx @@ -539,7 +539,12 @@ export const AlertsList: React.FunctionComponent = () => { fullWidth isClearable data-test-subj="alertSearchField" - onChange={(e) => setInputText(e.target.value)} + onChange={(e) => { + setInputText(e.target.value); + if (e.target.value === '') { + setSearchText(e.target.value); + } + }} onKeyUp={(e) => { if (e.keyCode === ENTER_KEY) { setSearchText(inputText); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts index 9095f8adbf3f4..79eb341f9bbfe 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts @@ -109,6 +109,43 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ]); }); + it('should update alert list on the search clear button click', async () => { + await createAlert({ name: 'b' }); + await createAlert({ name: 'c' }); + await refreshAlertsList(); + await pageObjects.triggersActionsUI.searchAlerts('b'); + + const searchResults = await pageObjects.triggersActionsUI.getAlertsList(); + expect(searchResults).to.eql([ + { + name: 'b', + tagsText: 'foo, bar', + alertType: 'Test: Noop', + interval: '1m', + }, + ]); + const searchClearButton = await find.byCssSelector('.euiFormControlLayoutClearButton'); + await searchClearButton.click(); + await find.byCssSelector( + '.euiBasicTable[data-test-subj="alertsList"]:not(.euiBasicTable-loading)' + ); + const searchResultsAfterClear = await pageObjects.triggersActionsUI.getAlertsList(); + expect(searchResultsAfterClear).to.eql([ + { + name: 'b', + tagsText: 'foo, bar', + alertType: 'Test: Noop', + interval: '1m', + }, + { + name: 'c', + tagsText: 'foo, bar', + alertType: 'Test: Noop', + interval: '1m', + }, + ]); + }); + it('should search for tags', async () => { const createdAlert = await createAlert(); await refreshAlertsList();