@@ -72,41 +72,36 @@ export const Filter: React.FC<Props> = ({ options, title, param }) => {
72
72
const isSelected = selected . includes ( option . value ) ;
73
73
74
74
return (
75
- < CommandItem
76
- /**
77
- * We're simulating next/link behavior here and prefetching the page when they hover over an item
78
- */
79
- onMouseEnter = { ( ) => {
80
- const copySelected = new Set ( selected ) ;
81
- if ( isSelected ) {
82
- copySelected . delete ( option . value ) ;
83
- } else {
84
- copySelected . add ( option . value ) ;
85
- }
86
- // params.prefetch(param, Array.from(copySelected).join(","));
87
- } }
88
- key = { option . value }
89
- onSelect = { ( ) => {
75
+ < div
76
+ onMouseDownCapture = { ( ) => {
90
77
const next = isSelected
91
78
? selected . filter ( ( v ) => v !== option . value )
92
79
: Array . from ( new Set ( [ ...selected , option . value ] ) ) ;
93
-
94
80
setSelected ( next ) ;
95
- // params.set(param, next);
96
81
} }
97
82
>
98
- < div
99
- className = { cn (
100
- "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary" ,
101
- isSelected
102
- ? "bg-primary text-primary-foreground"
103
- : "opacity-50 [&_svg]:invisible" ,
104
- ) }
83
+ < CommandItem
84
+ key = { option . value }
85
+ onSelect = { ( ) => {
86
+ const next = isSelected
87
+ ? selected . filter ( ( v ) => v !== option . value )
88
+ : Array . from ( new Set ( [ ...selected , option . value ] ) ) ;
89
+ setSelected ( next ) ;
90
+ } }
105
91
>
106
- < Check className = { cn ( "h-4 w-4" ) } />
107
- </ div >
108
- < span className = "truncate text-ellipsis" > { option . label } </ span >
109
- </ CommandItem >
92
+ < div
93
+ className = { cn (
94
+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary" ,
95
+ isSelected
96
+ ? "bg-primary text-primary-foreground"
97
+ : "opacity-50 [&_svg]:invisible" ,
98
+ ) }
99
+ >
100
+ < Check className = { cn ( "h-4 w-4" ) } />
101
+ </ div >
102
+ < span className = "truncate text-ellipsis" > { option . label } </ span >
103
+ </ CommandItem >
104
+ </ div >
110
105
) ;
111
106
} ) }
112
107
</ CommandGroup >
0 commit comments