From 7cb5aa5b7ff3fd622c411eb2ffa324011c5d9621 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Fri, 1 Dec 2023 19:10:11 -0500 Subject: [PATCH] fix(atomic-search-box): close suggestions when clicking search button (#3448) * fix(atomic-search-box): close suggestions when clicking search button https://coveord.atlassian.net/browse/KIT-2921 * test(atomic-search-box): close suggestions when clicking search button https://coveord.atlassian.net/browse/KIT-2921 --- .../cypress/e2e/search-box/search-box.cypress.ts | 10 ++++++++++ .../search/atomic-search-box/atomic-search-box.tsx | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/atomic/cypress/e2e/search-box/search-box.cypress.ts b/packages/atomic/cypress/e2e/search-box/search-box.cypress.ts index e925f91392c..68369e882be 100644 --- a/packages/atomic/cypress/e2e/search-box/search-box.cypress.ts +++ b/packages/atomic/cypress/e2e/search-box/search-box.cypress.ts @@ -487,6 +487,16 @@ describe('Search Box Test Suites', () => { .and('contain', 'active-suggestion'); }); + it('should collapse suggestions when clicking on the search button', () => { + SearchBoxSelectors.inputBox().focus(); + SearchBoxSelectors.querySuggestions().should('exist'); + + SearchBoxSelectors.submitButton().click(); + cy.wait(TestFixture.interceptAliases.Search); + + SearchBoxSelectors.querySuggestions().should('not.exist'); + }); + CommonAssertions.assertConsoleError(false); }); diff --git a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.tsx b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.tsx index 780c8f273f0..088e6956e55 100644 --- a/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.tsx +++ b/packages/atomic/src/components/search/atomic-search-box/atomic-search-box.tsx @@ -867,7 +867,10 @@ export class AtomicSearchBox { this.searchBox.submit()} + onClick={() => { + this.searchBox.submit(); + this.clearSuggestions(); + }} title={searchLabel} /> {this.renderSuggestions()}