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