Skip to content

Commit 24fc9da

Browse files
Merge pull request #443 from floriankapaun/bugfix/442
Bugfix/442
2 parents e843854 + ce8c635 commit 24fc9da

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

packages/mantine-react-table/src/components/inputs/MRT_FilterTextInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const MRT_FilterTextInput = <TData extends MRT_RowData>({
245245
: textInputProps?.style),
246246
},
247247
title: filterPlaceholder,
248-
value: filterValue,
248+
value: isMultiSelectFilter && !Array.isArray(filterValue) ? [] : filterValue,
249249
variant: 'unstyled',
250250
} as const;
251251

packages/mantine-react-table/stories/features/Filtering.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const columns: MRT_ColumnDef<(typeof data)[0]>[] = [
7171
const data = [...Array(120)].map(() => ({
7272
address: faker.location.streetAddress(),
7373
age: faker.number.int(100),
74-
birthDate: faker.date.birthdate({ max: 2020, min: 1990 }),
74+
birthDate: faker.date.birthdate({ max: 2020, min: 1990, mode: "year" }),
7575
firstName: faker.person.firstName(),
7676
gender: faker.person.sex(),
7777
hireDate: faker.date.past(),
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { MantineReactTable } from "../../src";
2+
import { type Meta } from '@storybook/react';
3+
4+
const meta: Meta = {
5+
title: 'Fixed Bugs/Filtering',
6+
};
7+
8+
export default meta;
9+
10+
export const SwitchFromEmptyToEqualsArray = () => (
11+
<MantineReactTable
12+
columns={[
13+
{
14+
accessorKey: 'id',
15+
header: 'ID',
16+
enableColumnFilterModes: false,
17+
},
18+
{
19+
accessorKey: 'state',
20+
header: 'State',
21+
filterVariant: 'multi-select',
22+
columnFilterModeOptions: ['equals', 'empty'],
23+
mantineFilterMultiSelectProps: {
24+
data: ["Wyoming", "Delaware", "South Dakota", "Vermont", "Rhode Island"]
25+
}
26+
},
27+
]}
28+
data={[{id: 1, state: ""}, {id: 2, state: "Wyoming"}]}
29+
enableColumnFilterModes
30+
initialState={{ showColumnFilters: true }}
31+
/>
32+
);

0 commit comments

Comments
 (0)