Skip to content

Commit 969b755

Browse files
fix: hide button sort if column cannot be hidden & update filterFn (#69)
* fix: hide button sort if column cannot be hidden & fix multiple filter on users table * fix: hide dropdown separators if column dropdown is disabled * fix: disable sorting for status and role columns --------- Co-authored-by: satnaing <[email protected]>
1 parent a1075bd commit 969b755

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

src/features/tasks/components/data-table-column-header.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ export function DataTableColumnHeader<TData, TValue>({
5858
<ArrowDownIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
5959
Desc
6060
</DropdownMenuItem>
61-
<DropdownMenuSeparator />
62-
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
63-
<EyeNoneIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
64-
Hide
65-
</DropdownMenuItem>
61+
{column.getCanHide() && (
62+
<>
63+
<DropdownMenuSeparator />
64+
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
65+
<EyeNoneIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
66+
Hide
67+
</DropdownMenuItem>
68+
</>
69+
)}
6670
</DropdownMenuContent>
6771
</DropdownMenu>
6872
</div>

src/features/users/components/data-table-column-header.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ export function DataTableColumnHeader<TData, TValue>({
5858
<ArrowDownIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
5959
Desc
6060
</DropdownMenuItem>
61-
<DropdownMenuSeparator />
62-
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
63-
<EyeNoneIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
64-
Hide
65-
</DropdownMenuItem>
61+
{column.getCanHide() && (
62+
<>
63+
<DropdownMenuSeparator />
64+
<DropdownMenuItem onClick={() => column.toggleVisibility(false)}>
65+
<EyeNoneIcon className='mr-2 h-3.5 w-3.5 text-muted-foreground/70' />
66+
Hide
67+
</DropdownMenuItem>
68+
</>
69+
)}
6670
</DropdownMenuContent>
6771
</DropdownMenu>
6872
</div>

src/features/users/components/users-columns.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ export const columns: ColumnDef<User>[] = [
101101
</div>
102102
)
103103
},
104-
filterFn: 'weakEquals',
105-
enableSorting: false,
104+
filterFn: (row, id, value) => {
105+
return value.includes(row.getValue(id))
106+
},
106107
enableHiding: false,
108+
enableSorting: false,
107109
},
108110
{
109111
accessorKey: 'role',
@@ -127,7 +129,9 @@ export const columns: ColumnDef<User>[] = [
127129
</div>
128130
)
129131
},
130-
filterFn: 'weakEquals',
132+
filterFn: (row, id, value) => {
133+
return value.includes(row.getValue(id))
134+
},
131135
enableSorting: false,
132136
enableHiding: false,
133137
},

0 commit comments

Comments
 (0)