Skip to content

Commit

Permalink
fix(filter-clear): disable clear button when value is empty array (#2067
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Sophmrs authored Jan 28, 2025
2 parents c812da5 + ad094ff commit 3ece22c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/shoreline/src/components/filter/filter-clear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ function useFilterClear() {
const selectValue = select?.useState('value') ?? ''
const filterValue = filter?.useState('value') ?? ''

const isSelectValueEmpty = Array.isArray(selectValue)
? selectValue.length === 0
: !selectValue
const isFilterValueEmpty = Array.isArray(filterValue)
? filterValue.length === 0
: !filterValue

return {
onClick() {
filter?.setValue(reset)
select?.setValue(reset)
},
disabled: !selectValue && !filterValue,
disabled: isSelectValueEmpty && isFilterValueEmpty,
}
}

Expand Down

0 comments on commit 3ece22c

Please sign in to comment.