From 535c175272e65a72009c9435135b80ff20b9ed91 Mon Sep 17 00:00:00 2001 From: saithsab877 Date: Sat, 14 Sep 2024 06:01:20 +0500 Subject: [PATCH 1/2] fix(filter-search): modal close after Show Result button, hide X icon --- src/components/App/SideBar/FilterSearch/index.tsx | 11 ++++++++++- src/components/App/SideBar/RegularView/index.tsx | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/App/SideBar/FilterSearch/index.tsx b/src/components/App/SideBar/FilterSearch/index.tsx index 429d459a6..c4ac939af 100644 --- a/src/components/App/SideBar/FilterSearch/index.tsx +++ b/src/components/App/SideBar/FilterSearch/index.tsx @@ -18,6 +18,7 @@ type Props = { schemaAll: SchemaExtended[] anchorEl: HTMLElement | null setAnchorEl: (value: HTMLElement | null) => void + onClose: () => void } const defaultValues = { @@ -27,7 +28,14 @@ const defaultValues = { maxResults: 30, } -export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anchorEl, setAnchorEl }: Props) => { +export const FilterSearch = ({ + showAllSchemas, + setShowAllSchemas, + schemaAll, + anchorEl, + setAnchorEl, + onClose, +}: Props) => { const handleSchemaTypeClick = (type: string) => { setSelectedTypes((prevSelectedTypes) => prevSelectedTypes.includes(type) ? prevSelectedTypes.filter((t) => t !== type) : [...prevSelectedTypes, type], @@ -65,6 +73,7 @@ export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anc }) setAnchorEl(null) + onClose() await fetchData(setBudget, setAbortRequests) } diff --git a/src/components/App/SideBar/RegularView/index.tsx b/src/components/App/SideBar/RegularView/index.tsx index 3cb54dadc..e4c2fe061 100644 --- a/src/components/App/SideBar/RegularView/index.tsx +++ b/src/components/App/SideBar/RegularView/index.tsx @@ -92,6 +92,11 @@ export const RegularView = () => { setShowAllSchemas(false) } + const handleCloseFilterSearch = () => { + setIsFilterOpen(false) + setAnchorEl(null) + } + const navigate = useNavigate() return ( @@ -136,6 +141,7 @@ export const RegularView = () => { Date: Tue, 17 Sep 2024 02:00:04 +0500 Subject: [PATCH 2/2] fix(unit-test): unit test --- src/components/App/SideBar/FilterSearch/__tests__/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/App/SideBar/FilterSearch/__tests__/index.tsx b/src/components/App/SideBar/FilterSearch/__tests__/index.tsx index ef73ba5a7..c09d6a4c2 100644 --- a/src/components/App/SideBar/FilterSearch/__tests__/index.tsx +++ b/src/components/App/SideBar/FilterSearch/__tests__/index.tsx @@ -18,6 +18,7 @@ const mockSetShowAllSchemas = jest.fn() const mockSetAnchorEl = jest.fn() const mockFetchData = jest.fn() const mockSetAbortRequests = jest.fn() +const mockOnClose = jest.fn() const mockSchemaAll = [{ type: 'Type1' }, { type: 'Type2' }, { type: 'Type3' }, { type: 'Type4' }, { type: 'Type5' }] @@ -28,6 +29,7 @@ describe('FilterSearch Component', () => { setFilters: mockSetFilters, fetchData: mockFetchData, setAbortRequests: mockSetAbortRequests, + onClose: mockOnClose, }) }) @@ -37,6 +39,7 @@ describe('FilterSearch Component', () => { {