@@ -123,7 +123,7 @@ const useAutocomplete = <TOption extends BaseOption = BaseOption>({
123
123
onChange,
124
124
} : UseAutocompleteOptions < TOption > ) => {
125
125
const [ query , setQuery ] = useState ( "" )
126
- const [ selectedOption , setSelectedOption ] = useState < BaseOption > ( )
126
+ const [ selectedOption , setSelectedOption ] = useState < TOption > ( )
127
127
const initialOptionQuery = useQuery ( {
128
128
queryKey : [ id , "autocomplete" , "initial" ] ,
129
129
queryFn : ( ) => getInitialOption ( ) ,
@@ -136,7 +136,7 @@ const useAutocomplete = <TOption extends BaseOption = BaseOption>({
136
136
const selectOption = ( option : TOption ) => {
137
137
let newSelectedOptionValue : TOption | undefined = option
138
138
139
- if ( option . label === selectedOption ?. value ) {
139
+ if ( option . value === selectedOption ?. value ) {
140
140
newSelectedOptionValue = undefined
141
141
}
142
142
@@ -294,9 +294,9 @@ export const Filter = ({
294
294
return (
295
295
< Box display = "flex" sx = { { gap : 1 , mb : 2 } } >
296
296
< FilterSkeleton width = "100%" />
297
- < FilterSkeleton width = { 120 } />
298
- < FilterSkeleton width = { 120 } />
299
- < FilterSkeleton width = { 120 } />
297
+ < FilterSkeleton width = "200px" />
298
+ < FilterSkeleton width = "200px" />
299
+ < FilterSkeleton width = "200px" />
300
300
</ Box >
301
301
)
302
302
}
@@ -355,8 +355,16 @@ const OwnerFilter = ({ autocomplete }: { autocomplete: UsersAutocomplete }) => {
355
355
356
356
return (
357
357
< div >
358
- < MenuButton ref = { buttonRef } onClick = { ( ) => setIsMenuOpen ( true ) } >
359
- User
358
+ < MenuButton
359
+ ref = { buttonRef }
360
+ onClick = { ( ) => setIsMenuOpen ( true ) }
361
+ sx = { { width : 200 } }
362
+ >
363
+ { autocomplete . selectedOption ? (
364
+ < UserOptionItem option = { autocomplete . selectedOption } />
365
+ ) : (
366
+ "All users"
367
+ ) }
360
368
</ MenuButton >
361
369
< SearchMenu
362
370
id = "user-filter-menu"
@@ -373,21 +381,27 @@ const OwnerFilter = ({ autocomplete }: { autocomplete: UsersAutocomplete }) => {
373
381
handleClose ( )
374
382
} }
375
383
>
376
- < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
377
- < UserAvatar
378
- username = { option . label }
379
- avatarURL = { option . avatarUrl }
380
- sx = { { width : 16 , height : 16 , fontSize : 8 } }
381
- />
382
- < span > { option . label } </ span >
383
- </ Box >
384
+ < UserOptionItem option = { option } />
384
385
</ MenuItem >
385
386
) }
386
387
/>
387
388
</ div >
388
389
)
389
390
}
390
391
392
+ const UserOptionItem = ( { option } : { option : OwnerOption } ) => {
393
+ return (
394
+ < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
395
+ < UserAvatar
396
+ username = { option . label }
397
+ avatarURL = { option . avatarUrl }
398
+ sx = { { width : 16 , height : 16 , fontSize : 8 } }
399
+ />
400
+ < span > { option . label } </ span >
401
+ </ Box >
402
+ )
403
+ }
404
+
391
405
const TemplatesFilter = ( {
392
406
autocomplete,
393
407
} : {
@@ -402,8 +416,16 @@ const TemplatesFilter = ({
402
416
403
417
return (
404
418
< div >
405
- < MenuButton ref = { buttonRef } onClick = { ( ) => setIsMenuOpen ( true ) } >
406
- Template
419
+ < MenuButton
420
+ ref = { buttonRef }
421
+ onClick = { ( ) => setIsMenuOpen ( true ) }
422
+ sx = { { width : 200 } }
423
+ >
424
+ { autocomplete . selectedOption ? (
425
+ < TemplateOptionItem option = { autocomplete . selectedOption } />
426
+ ) : (
427
+ "All templates"
428
+ ) }
407
429
</ MenuButton >
408
430
< SearchMenu
409
431
id = "template-filter-menu"
@@ -420,21 +442,27 @@ const TemplatesFilter = ({
420
442
handleClose ( )
421
443
} }
422
444
>
423
- < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
424
- < TemplateAvatar
425
- templateName = { option . label }
426
- icon = { option . icon }
427
- sx = { { width : 14 , height : 14 , fontSize : 8 } }
428
- />
429
- < span > { option . label } </ span >
430
- </ Box >
445
+ < TemplateOptionItem option = { option } />
431
446
</ MenuItem >
432
447
) }
433
448
/>
434
449
</ div >
435
450
)
436
451
}
437
452
453
+ const TemplateOptionItem = ( { option } : { option : TemplateOption } ) => {
454
+ return (
455
+ < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
456
+ < TemplateAvatar
457
+ templateName = { option . label }
458
+ icon = { option . icon }
459
+ sx = { { width : 14 , height : 14 , fontSize : 8 } }
460
+ />
461
+ < span > { option . label } </ span >
462
+ </ Box >
463
+ )
464
+ }
465
+
438
466
const TemplateAvatar : FC <
439
467
AvatarProps & { templateName : string ; icon ?: string }
440
468
> = ( { templateName, icon, ...avatarProps } ) => {
@@ -459,14 +487,23 @@ const StatusFilter = ({
459
487
460
488
return (
461
489
< div >
462
- < MenuButton ref = { buttonRef } onClick = { ( ) => setIsMenuOpen ( true ) } >
463
- Status
490
+ < MenuButton
491
+ ref = { buttonRef }
492
+ onClick = { ( ) => setIsMenuOpen ( true ) }
493
+ sx = { { width : 200 } }
494
+ >
495
+ { autocomplete . selectedOption ? (
496
+ < StatusOptionItem option = { autocomplete . selectedOption } />
497
+ ) : (
498
+ "All statuses"
499
+ ) }
464
500
</ MenuButton >
465
501
< Menu
466
502
id = "status-filter-menu"
467
503
anchorEl = { buttonRef . current }
468
504
open = { isMenuOpen }
469
505
onClose = { handleClose }
506
+ sx = { { "& .MuiPaper-root" : { minWidth : 200 } } }
470
507
>
471
508
{ autocomplete . searchOptions ?. map ( ( option ) => (
472
509
< MenuItem
@@ -477,17 +514,23 @@ const StatusFilter = ({
477
514
handleClose ( )
478
515
} }
479
516
>
480
- < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
481
- < StatusIndicator option = { option } />
482
- < span > { option . label } </ span >
483
- </ Box >
517
+ < StatusOptionItem option = { option } />
484
518
</ MenuItem >
485
519
) ) }
486
520
</ Menu >
487
521
</ div >
488
522
)
489
523
}
490
524
525
+ const StatusOptionItem = ( { option } : { option : StatusOption } ) => {
526
+ return (
527
+ < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
528
+ < StatusIndicator option = { option } />
529
+ < span > { option . label } </ span >
530
+ </ Box >
531
+ )
532
+ }
533
+
491
534
const StatusIndicator : FC < { option : StatusOption } > = ( { option } ) => {
492
535
return (
493
536
< Box
@@ -511,6 +554,7 @@ const MenuButton = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
511
554
sx = { {
512
555
borderRadius : "6px" ,
513
556
lineHeight : 0 ,
557
+ justifyContent : "space-between" ,
514
558
...props . sx ,
515
559
} }
516
560
/>
0 commit comments