fix: deselecting filter option when clicked again (#528)

* fix: filters dropdown overflowing issue

* filters dropdown z-index

* fix: deselecting filter option when clicked again

---------

Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
This commit is contained in:
Dakshesh Jain 2023-03-24 23:33:28 +05:30 committed by GitHub
parent f2054b6945
commit 82b9275609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,16 +71,29 @@ export const IssuesFilterView: React.FC = () => {
<SelectFilters
filters={filters}
onSelect={(option) => {
const key = option.key as keyof typeof filters;
const valueExists = filters[key]?.includes(option.value);
if (valueExists) {
setFilters(
{
...filters,
[option.key]: [
...((filters?.[option.key as keyof typeof filters] as any[]) ?? []),
option.value,
],
...(filters ?? {}),
[option.key]: ((filters[key] ?? []) as any[])?.filter(
(val) => val !== option.value
),
},
!Boolean(viewId)
);
} else {
setFilters(
{
...(filters ?? {}),
[option.key]: [...((filters[key] ?? []) as any[]), option.value],
},
!Boolean(viewId)
);
}
}}
direction="left"
height="rg"