@@ -21,6 +21,7 @@ import { useSearchParams } from "react-router-dom"
21
21
import { useQuery } from "@tanstack/react-query"
22
22
import { getUsers , getTemplates } from "api/api"
23
23
import Skeleton , { SkeletonProps } from "@mui/material/Skeleton"
24
+ import CheckOutlined from "@mui/icons-material/CheckOutlined"
24
25
25
26
/** Filter */
26
27
@@ -431,32 +432,36 @@ const OwnerFilter = ({ autocomplete }: { autocomplete: UsersAutocomplete }) => {
431
432
handleClose ( )
432
433
} }
433
434
>
434
- < UserOptionItem option = { option } />
435
+ < UserOptionItem
436
+ option = { option }
437
+ isSelected = { option . value === autocomplete . selectedOption ?. value }
438
+ />
435
439
</ MenuItem >
436
440
) }
437
441
/>
438
442
</ div >
439
443
)
440
444
}
441
445
442
- const UserOptionItem = ( { option } : { option : OwnerOption } ) => {
446
+ const UserOptionItem = ( {
447
+ option,
448
+ isSelected,
449
+ } : {
450
+ option : OwnerOption
451
+ isSelected ?: boolean
452
+ } ) => {
443
453
return (
444
- < Box
445
- display = "flex"
446
- alignItems = "center"
447
- gap = { 2 }
448
- fontSize = { 14 }
449
- overflow = "hidden"
450
- >
451
- < UserAvatar
452
- username = { option . label }
453
- avatarURL = { option . avatarUrl }
454
- sx = { { width : 16 , height : 16 , fontSize : 8 } }
455
- />
456
- < Box component = "span" overflow = "hidden" textOverflow = "ellipsis" >
457
- { option . label }
458
- </ Box >
459
- </ Box >
454
+ < OptionItem
455
+ option = { option }
456
+ isSelected = { isSelected }
457
+ left = {
458
+ < UserAvatar
459
+ username = { option . label }
460
+ avatarURL = { option . avatarUrl }
461
+ sx = { { width : 16 , height : 16 , fontSize : 8 } }
462
+ />
463
+ }
464
+ />
460
465
)
461
466
}
462
467
@@ -502,32 +507,36 @@ const TemplatesFilter = ({
502
507
handleClose ( )
503
508
} }
504
509
>
505
- < TemplateOptionItem option = { option } />
510
+ < TemplateOptionItem
511
+ option = { option }
512
+ isSelected = { option . value === autocomplete . selectedOption ?. value }
513
+ />
506
514
</ MenuItem >
507
515
) }
508
516
/>
509
517
</ div >
510
518
)
511
519
}
512
520
513
- const TemplateOptionItem = ( { option } : { option : TemplateOption } ) => {
521
+ const TemplateOptionItem = ( {
522
+ option,
523
+ isSelected,
524
+ } : {
525
+ option : TemplateOption
526
+ isSelected ?: boolean
527
+ } ) => {
514
528
return (
515
- < Box
516
- display = "flex"
517
- alignItems = "center"
518
- gap = { 2 }
519
- fontSize = { 14 }
520
- overflow = "hidden"
521
- >
522
- < TemplateAvatar
523
- templateName = { option . label }
524
- icon = { option . icon }
525
- sx = { { width : 14 , height : 14 , fontSize : 8 } }
526
- />
527
- < Box component = "span" overflow = "hidden" textOverflow = "ellipsis" >
528
- { option . label }
529
- </ Box >
530
- </ Box >
529
+ < OptionItem
530
+ option = { option }
531
+ isSelected = { isSelected }
532
+ left = {
533
+ < TemplateAvatar
534
+ templateName = { option . label }
535
+ icon = { option . icon }
536
+ sx = { { width : 14 , height : 14 , fontSize : 8 } }
537
+ />
538
+ }
539
+ />
531
540
)
532
541
}
533
542
@@ -589,20 +598,30 @@ const StatusFilter = ({
589
598
handleClose ( )
590
599
} }
591
600
>
592
- < StatusOptionItem option = { option } />
601
+ < StatusOptionItem
602
+ option = { option }
603
+ isSelected = { option . value === autocomplete . selectedOption ?. value }
604
+ />
593
605
</ MenuItem >
594
606
) ) }
595
607
</ Menu >
596
608
</ div >
597
609
)
598
610
}
599
611
600
- const StatusOptionItem = ( { option } : { option : StatusOption } ) => {
612
+ const StatusOptionItem = ( {
613
+ option,
614
+ isSelected,
615
+ } : {
616
+ option : StatusOption
617
+ isSelected ?: boolean
618
+ } ) => {
601
619
return (
602
- < Box display = "flex" alignItems = "center" gap = { 2 } fontSize = { 14 } >
603
- < StatusIndicator option = { option } />
604
- < span > { option . label } </ span >
605
- </ Box >
620
+ < OptionItem
621
+ option = { option }
622
+ left = { < StatusIndicator option = { option } /> }
623
+ isSelected = { isSelected }
624
+ />
606
625
)
607
626
}
608
627
@@ -620,6 +639,33 @@ const StatusIndicator: FC<{ option: StatusOption }> = ({ option }) => {
620
639
)
621
640
}
622
641
642
+ type OptionItemProps = {
643
+ option : BaseOption
644
+ left ?: ReactNode
645
+ isSelected ?: boolean
646
+ }
647
+
648
+ const OptionItem = ( { option, left, isSelected } : OptionItemProps ) => {
649
+ return (
650
+ < Box
651
+ display = "flex"
652
+ alignItems = "center"
653
+ gap = { 2 }
654
+ fontSize = { 14 }
655
+ overflow = "hidden"
656
+ width = "100%"
657
+ >
658
+ { left }
659
+ < Box component = "span" overflow = "hidden" textOverflow = "ellipsis" >
660
+ { option . label }
661
+ </ Box >
662
+ { isSelected && (
663
+ < CheckOutlined sx = { { width : 16 , height : 16 , marginLeft : "auto" } } />
664
+ ) }
665
+ </ Box >
666
+ )
667
+ }
668
+
623
669
const MenuButton = forwardRef < HTMLButtonElement , ButtonProps > ( ( props , ref ) => {
624
670
return (
625
671
< Button
0 commit comments