Skip to content
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

fix: Auditlogs Filters now can be clicked on #2639

Open
wants to merge 4 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
51 changes: 23 additions & 28 deletions apps/dashboard/app/(app)/audit/[bucket]/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,41 +72,36 @@ export const Filter: React.FC<Props> = ({ options, title, param }) => {
const isSelected = selected.includes(option.value);

return (
<CommandItem
/**
* We're simulating next/link behavior here and prefetching the page when they hover over an item
*/
onMouseEnter={() => {
const copySelected = new Set(selected);
if (isSelected) {
copySelected.delete(option.value);
} else {
copySelected.add(option.value);
}
// params.prefetch(param, Array.from(copySelected).join(","));
}}
key={option.value}
onSelect={() => {
<div
onMouseDownCapture={() => {
const next = isSelected
? selected.filter((v) => v !== option.value)
: Array.from(new Set([...selected, option.value]));

setSelected(next);
// params.set(param, next);
}}
>
Comment on lines +75 to 82
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add key prop to the wrapper div.

The wrapper div in the iteration is missing a key prop, which is required for React's reconciliation process.

Apply this change:

  <div
+   key={option.value}
    onMouseDownCapture={() => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
onMouseDownCapture={() => {
const next = isSelected
? selected.filter((v) => v !== option.value)
: Array.from(new Set([...selected, option.value]));
setSelected(next);
// params.set(param, next);
}}
>
<div
key={option.value}
onMouseDownCapture={() => {
const next = isSelected
? selected.filter((v) => v !== option.value)
: Array.from(new Set([...selected, option.value]));
setSelected(next);
}}
>
🧰 Tools
🪛 Biome

[error] 75-82: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

<div
className={cn(
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
isSelected
? "bg-primary text-primary-foreground"
: "opacity-50 [&_svg]:invisible",
)}
<CommandItem
key={option.value}
onSelect={() => {
const next = isSelected
? selected.filter((v) => v !== option.value)
: Array.from(new Set([...selected, option.value]));
setSelected(next);
}}
>
<Check className={cn("h-4 w-4")} />
</div>
<span className="truncate text-ellipsis">{option.label}</span>
</CommandItem>
<div
className={cn(
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
isSelected
? "bg-primary text-primary-foreground"
: "opacity-50 [&_svg]:invisible",
)}
>
<Check className={cn("h-4 w-4")} />
</div>
<span className="truncate text-ellipsis">{option.label}</span>
</CommandItem>
</div>
);
})}
</CommandGroup>
Expand Down