@@ -72,41 +72,35 @@ export const Filter: React.FC<Props> = ({ options, title, param }) => {
72
72
const isSelected = selected . includes ( option . value ) ;
73
73
74
74
return (
75
+ < div
76
+ onMouseDownCapture = { ( ) => {
77
+
78
+ const next = isSelected
79
+ ? selected . filter ( ( v ) => v !== option . value )
80
+ : Array . from ( new Set ( [ ...selected , option . value ] ) ) ;
81
+ setSelected ( next ) ;
82
+ } }
83
+ >
75
84
< 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
85
key = { option . value }
89
86
onSelect = { ( ) => {
90
87
const next = isSelected
91
88
? selected . filter ( ( v ) => v !== option . value )
92
89
: Array . from ( new Set ( [ ...selected , option . value ] ) ) ;
93
-
94
90
setSelected ( next ) ;
95
- // params.set(param, next);
96
91
} }
97
92
>
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
- ) }
105
- >
93
+ < div 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
+ ) } >
106
99
< Check className = { cn ( "h-4 w-4" ) } />
107
100
</ div >
108
101
< span className = "truncate text-ellipsis" > { option . label } </ span >
109
102
</ CommandItem >
103
+ </ div >
110
104
) ;
111
105
} ) }
112
106
</ CommandGroup >
0 commit comments