Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FilterSearch]: Modal closes after clicking Show Result button, but the cross (X) icon remains visible #2137

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/App/SideBar/FilterSearch/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' }]

Expand All @@ -28,6 +29,7 @@ describe('FilterSearch Component', () => {
setFilters: mockSetFilters,
fetchData: mockFetchData,
setAbortRequests: mockSetAbortRequests,
onClose: mockOnClose,
})
})

Expand All @@ -37,6 +39,7 @@ describe('FilterSearch Component', () => {
<StyleThemeProvider theme={appTheme}>
<FilterSearch
anchorEl={document.createElement('div')}
onClose={mockOnClose}
schemaAll={mockSchemaAll}
setAnchorEl={mockSetAnchorEl}
setShowAllSchemas={mockSetShowAllSchemas}
Expand Down Expand Up @@ -174,6 +177,7 @@ describe('FilterSearch Component', () => {
<StyleThemeProvider theme={appTheme}>
<FilterSearch
anchorEl={null}
onClose={mockOnClose}
schemaAll={mockSchemaAll}
setAnchorEl={mockSetAnchorEl}
setShowAllSchemas={mockSetShowAllSchemas}
Expand Down
11 changes: 10 additions & 1 deletion src/components/App/SideBar/FilterSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
schemaAll: SchemaExtended[]
anchorEl: HTMLElement | null
setAnchorEl: (value: HTMLElement | null) => void
onClose: () => void
}

const defaultValues = {
Expand All @@ -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],
Expand Down Expand Up @@ -65,6 +73,7 @@ export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anc
})

setAnchorEl(null)
onClose()

await fetchData(setBudget, setAbortRequests)
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/App/SideBar/RegularView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export const RegularView = () => {
setShowAllSchemas(false)
}

const handleCloseFilterSearch = () => {
setIsFilterOpen(false)
setAnchorEl(null)
}

const navigate = useNavigate()

return (
Expand Down Expand Up @@ -136,6 +141,7 @@ export const RegularView = () => {

<FilterSearch
anchorEl={anchorEl}
onClose={handleCloseFilterSearch}
schemaAll={schemaAll}
setAnchorEl={setAnchorEl}
setShowAllSchemas={setShowAllSchemas}
Expand Down
Loading