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 <SelectFilters
filters={filters} filters={filters}
onSelect={(option) => { onSelect={(option) => {
setFilters( const key = option.key as keyof typeof filters;
{
...filters, const valueExists = filters[key]?.includes(option.value);
[option.key]: [
...((filters?.[option.key as keyof typeof filters] as any[]) ?? []), if (valueExists) {
option.value, setFilters(
], {
}, ...(filters ?? {}),
!Boolean(viewId) [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" direction="left"
height="rg" height="rg"