diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GlobalSearch/GlobalSearch_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GlobalSearch/GlobalSearch_spec.js index a546ab9135..f5ab1b1f82 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GlobalSearch/GlobalSearch_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/GlobalSearch/GlobalSearch_spec.js @@ -1,6 +1,7 @@ /* eslint-disable cypress/no-unnecessary-waiting */ const commonlocators = require("../../../../locators/commonlocators.json"); const dsl = require("../../../../fixtures/MultipleWidgetDsl.json"); +const globalSearchLocators = require("../../../../locators/GlobalSearch.json"); describe("GlobalSearch", function() { before(() => { @@ -11,6 +12,14 @@ describe("GlobalSearch", function() { cy.startRoutesForDatasource(); }); + it("Clicking on filter should show the filter menu", () => { + cy.get(commonlocators.globalSearchTrigger).click({ force: true }); + cy.contains(globalSearchLocators.docHint, "Snippets").click(); + cy.get(globalSearchLocators.filterButton).click(); + cy.contains("Reset Filter").should("be.visible"); + cy.get("body").type("{esc}"); + }); + it("1. showsAndHidesUsingKeyboardShortcuts", () => { // wait for the page to load cy.get(commonlocators.canvas); diff --git a/app/client/cypress/locators/GlobalSearch.json b/app/client/cypress/locators/GlobalSearch.json new file mode 100644 index 0000000000..7d5aaf5d0d --- /dev/null +++ b/app/client/cypress/locators/GlobalSearch.json @@ -0,0 +1,4 @@ +{ + "docHint": ".t--docHit", + "filterButton": ".t--filter-button" +} \ No newline at end of file diff --git a/app/client/src/components/editorComponents/GlobalSearch/SnippetsFilter.tsx b/app/client/src/components/editorComponents/GlobalSearch/SnippetsFilter.tsx index 287749bb38..afeea1eea7 100644 --- a/app/client/src/components/editorComponents/GlobalSearch/SnippetsFilter.tsx +++ b/app/client/src/components/editorComponents/GlobalSearch/SnippetsFilter.tsx @@ -133,7 +133,8 @@ function SnippetsFilter({ refinements, snippetsEmpty }: any) { const ref = useRef(null); const handleOutsideClick = useCallback( (e: MouseEvent) => { - if (ref && !ref.current?.contains(e?.target as Node)) + // Check if the clicked element has the `ref` element in the path(i.e parent list). + if (ref && !e.composedPath().includes(ref?.current as EventTarget)) toggleSnippetFilter(false); }, [showSnippetFilter], @@ -161,7 +162,7 @@ function SnippetsFilter({ refinements, snippetsEmpty }: any) { snippetsEmpty={snippetsEmpty} > -
+
{