Skip to content

fix: checkbox filter disappearing fix #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/data-table/data-table-filter-checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export function DataTableFilterCheckbox<TData>({
</div>
);

if (!filterOptions?.length) return null;

return (
<div className="grid gap-2">
{options && options.length > 4 ? (
Expand All @@ -73,7 +71,7 @@ export function DataTableFilterCheckbox<TData>({
) : null}
{/* FIXME: due to the added max-h and overflow-y-auto, the hover state and border is laying on top of the scroll bar */}
<div className="max-h-[200px] overflow-y-auto rounded-lg border border-border empty:border-none">
{filterOptions
{filterOptions!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of forcing it with !, can we use optional chaining (?) instead?

// TODO: we shoudn't sort the options here, instead filterOptions should be sorted by default
// .sort((a, b) => a.label.localeCompare(b.label))
.map((option, index) => {
Expand All @@ -84,7 +82,7 @@ export function DataTableFilterCheckbox<TData>({
key={String(option.value)}
className={cn(
"group relative flex items-center space-x-2 px-2 py-2.5 hover:bg-accent/50",
index !== filterOptions.length - 1 ? "border-b" : undefined,
index !== filterOptions!.length - 1 ? "border-b" : undefined,
)}
>
<Checkbox
Expand Down