Skip to content

Commit

Permalink
Merge pull request #1512 from habx/fix/all-value
Browse files Browse the repository at this point in the history
fix(SelectFilter): all value
  • Loading branch information
habxtech authored Nov 14, 2022
2 parents 1e628bf + 3ee16b6 commit a76f626
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/filter/SelectFilter/SelectFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { Column } from '../../index'

export const SelectFilter = React.forwardRef<HTMLDivElement, SelectFilterProps>(
(props, ref) => {
const { options, multi = false, column, ...other } = props
const { options, multi = false, column, allValue = 'all', ...other } = props
const defaultValue = React.useMemo(
() => (multi || !other.canSelectAll ? undefined : 'all'),
[multi, other.canSelectAll]
() => (multi || !other.canSelectAll ? undefined : allValue),
[multi, other.canSelectAll, allValue]
)
const filter = column.filterValue
const handleChange = column.setFilter
Expand All @@ -25,8 +25,8 @@ export const SelectFilter = React.forwardRef<HTMLDivElement, SelectFilterProps>(
() =>
multi || !other.canSelectAll
? options
: [{ value: 'all', label: 'Tout' }, ...options],
[options, multi, other.canSelectAll]
: [{ value: allValue, label: 'Tout' }, ...options],
[options, multi, other.canSelectAll, allValue]
)

return (
Expand All @@ -49,4 +49,6 @@ export const SelectFilter = React.forwardRef<HTMLDivElement, SelectFilterProps>(

export interface SelectFilterProps extends SelectProps {
column: Column<any>
/** @default all */
allValue?: any
}

0 comments on commit a76f626

Please sign in to comment.