@@ -231,17 +231,20 @@ const MultipleSelector = React.forwardRef<
231
231
[ selected ] ,
232
232
) ;
233
233
234
- const handleClickOutside = ( event : MouseEvent | TouchEvent ) => {
235
- if (
236
- dropdownRef . current &&
237
- ! dropdownRef . current . contains ( event . target as Node ) &&
238
- inputRef . current &&
239
- ! inputRef . current . contains ( event . target as Node )
240
- ) {
241
- setOpen ( false ) ;
242
- inputRef . current . blur ( ) ;
243
- }
244
- } ;
234
+ const handleClickOutside = React . useCallback (
235
+ ( event : MouseEvent | TouchEvent ) => {
236
+ if (
237
+ dropdownRef . current &&
238
+ ! dropdownRef . current . contains ( event . target as Node ) &&
239
+ inputRef . current &&
240
+ ! inputRef . current . contains ( event . target as Node )
241
+ ) {
242
+ setOpen ( false ) ;
243
+ inputRef . current . blur ( ) ;
244
+ }
245
+ } ,
246
+ [ ] ,
247
+ ) ;
245
248
246
249
const handleUnselect = React . useCallback (
247
250
( option : Option ) => {
@@ -287,7 +290,7 @@ const MultipleSelector = React.forwardRef<
287
290
document . removeEventListener ( "mousedown" , handleClickOutside ) ;
288
291
document . removeEventListener ( "touchend" , handleClickOutside ) ;
289
292
} ;
290
- } , [ open ] ) ;
293
+ } , [ open , handleClickOutside ] ) ;
291
294
292
295
useEffect ( ( ) => {
293
296
if ( value ) {
@@ -304,7 +307,7 @@ const MultipleSelector = React.forwardRef<
304
307
if ( JSON . stringify ( newOption ) !== JSON . stringify ( options ) ) {
305
308
setOptions ( newOption ) ;
306
309
}
307
- } , [ arrayDefaultOptions , arrayOptions , groupBy , onSearch , options ] ) ;
310
+ } , [ arrayOptions , groupBy , onSearch , options ] ) ;
308
311
309
312
useEffect ( ( ) => {
310
313
/** sync search */
@@ -328,7 +331,13 @@ const MultipleSelector = React.forwardRef<
328
331
329
332
void exec ( ) ;
330
333
// eslint-disable-next-line react-hooks/exhaustive-deps
331
- } , [ debouncedSearchTerm , groupBy , open , triggerSearchOnFocus ] ) ;
334
+ } , [
335
+ debouncedSearchTerm ,
336
+ groupBy ,
337
+ open ,
338
+ triggerSearchOnFocus ,
339
+ onSearchSync ,
340
+ ] ) ;
332
341
333
342
useEffect ( ( ) => {
334
343
/** async search */
@@ -353,8 +362,7 @@ const MultipleSelector = React.forwardRef<
353
362
} ;
354
363
355
364
void exec ( ) ;
356
- // eslint-disable-next-line react-hooks/exhaustive-deps
357
- } , [ debouncedSearchTerm , groupBy , open , triggerSearchOnFocus ] ) ;
365
+ } , [ debouncedSearchTerm , groupBy , open , triggerSearchOnFocus , onSearch ] ) ;
358
366
359
367
const CreatableItem = ( ) => {
360
368
if ( ! creatable ) return undefined ;
@@ -455,6 +463,7 @@ const MultipleSelector = React.forwardRef<
455
463
} // When onSearch is provided, we don't want to filter the options. You can still override it.
456
464
filter = { commandFilter ( ) }
457
465
>
466
+ { /* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */ }
458
467
< div
459
468
className = { cn (
460
469
"min-h-9 rounded-md border border-solid border-border text-sm " ,
@@ -484,8 +493,9 @@ const MultipleSelector = React.forwardRef<
484
493
>
485
494
{ option . label }
486
495
< button
496
+ type = "button"
487
497
className = { cn (
488
- "ml-1 pr-0 py-1 rounded-full bg-transparent border-none outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 " ,
498
+ "ml-1 pr-0 rounded-full bg-transparent border-none outline-none focus:ring-2 focus:ring-surface-invert-primary focus:ml-2.5 focus:pl-0 " ,
489
499
( disabled || option . fixed ) && "hidden" ,
490
500
) }
491
501
onKeyDown = { ( e ) => {
@@ -588,7 +598,8 @@ const MultipleSelector = React.forwardRef<
588
598
heading = { key }
589
599
className = "h-full overflow-auto"
590
600
>
591
- { /* biome-ignore lint/complexity/noUselessFragments: <explanation> */ }
601
+ { /* biome-ignore lint/complexity/noUselessFragments: A parent element is
602
+ needed for multiple dropdown items */ }
592
603
< >
593
604
{ dropdowns . map ( ( option ) => {
594
605
return (
0 commit comments