File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
compass-components/src/components Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ type InteractivePopoverProps = {
6060 containedElements ?: string [ ] ;
6161 containerClassName ?: string ;
6262 closeButtonClassName ?: string ;
63+ blurTriggerOnClose ?: boolean ;
6364} & Pick <
6465 React . ComponentProps < typeof Popover > ,
6566 'align' | 'justify' | 'spacing' | 'popoverZIndex'
@@ -80,6 +81,7 @@ function InteractivePopover({
8081 popoverZIndex,
8182 containerClassName,
8283 closeButtonClassName,
84+ blurTriggerOnClose = false ,
8385} : InteractivePopoverProps ) : React . ReactElement {
8486 const darkMode = useDarkMode ( ) ;
8587 const triggerRef = useRef < HTMLButtonElement > ( null ) ;
@@ -91,9 +93,13 @@ function InteractivePopover({
9193
9294 // Return focus to the trigger when the popover is hidden.
9395 setTimeout ( ( ) => {
94- triggerRef . current ?. focus ( ) ;
96+ if ( blurTriggerOnClose ) {
97+ triggerRef . current ?. blur ( ) ;
98+ } else {
99+ triggerRef . current ?. focus ( ) ;
100+ }
95101 } ) ;
96- } , [ setOpen ] ) ;
102+ } , [ setOpen , blurTriggerOnClose ] ) ;
97103
98104 const onClickTrigger = useCallback (
99105 ( event ) => {
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ export default function ConnectionsFilterPopover({
6767 [ onFilterChange ]
6868 ) ;
6969
70- const excludeInactiveId = useId ( 'Sort by' ) ;
70+ const excludeInactiveToggleId = useId ( 'exclude-inactive-toggle' ) ;
71+ const excludeInactiveLabelId = useId ( 'exclude-inactive-label' ) ;
7172
7273 // Add future filters to the boolean below
7374 const isActivated = filter . excludeInactive ;
@@ -76,13 +77,14 @@ export default function ConnectionsFilterPopover({
7677 < InteractivePopover
7778 open = { open }
7879 setOpen = { setOpen }
80+ blurTriggerOnClose
7981 closeButtonClassName = { closeButtonStyles }
8082 containerClassName = { containerStyles }
8183 trigger = { ( { onClick, children, ref } ) => (
8284 < >
8385 < Tooltip
8486 align = "right"
85- enabled = { ! open }
87+ /* enabled={!open} */
8688 trigger = {
8789 < IconButton
8890 onClick = { onClick }
@@ -116,12 +118,15 @@ export default function ConnectionsFilterPopover({
116118 < Overline > Filter Options</ Overline >
117119 < div className = { groupStyles } >
118120 < Toggle
119- aria-labelledby = { excludeInactiveId }
121+ id = { excludeInactiveToggleId }
122+ aria-labelledby = { excludeInactiveLabelId }
120123 checked = { filter . excludeInactive }
121124 onChange = { onExcludeInactiveChange }
122125 size = "small"
123126 />
124- < Label htmlFor = { excludeInactiveId } > Show only active connections</ Label >
127+ < Label htmlFor = { excludeInactiveToggleId } id = { excludeInactiveLabelId } >
128+ Show only active connections
129+ </ Label >
125130 </ div >
126131 </ InteractivePopover >
127132 ) ;
You can’t perform that action at this time.
0 commit comments