@@ -110,7 +110,7 @@ function MenuFn<TTag extends ElementType = typeof DEFAULT_MENU_TAG>(
110
110
111
111
if ( ! isFocusableElement ( target , FocusableMode . Loose ) ) {
112
112
event . preventDefault ( )
113
- buttonElement ?. focus ( )
113
+ machine . state . buttonElement ?. focus ( )
114
114
}
115
115
} )
116
116
@@ -449,7 +449,7 @@ function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(
449
449
dataRef . current ?. domRef . current ?. click ( )
450
450
}
451
451
machine . send ( { type : ActionTypes . CloseMenu } )
452
- restoreFocusIfNecessary ( buttonElement )
452
+ restoreFocusIfNecessary ( machine . state . buttonElement )
453
453
break
454
454
455
455
case Keys . ArrowDown :
@@ -478,15 +478,15 @@ function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(
478
478
event . preventDefault ( )
479
479
event . stopPropagation ( )
480
480
flushSync ( ( ) => machine . send ( { type : ActionTypes . CloseMenu } ) )
481
- buttonElement ?. focus ( { preventScroll : true } )
481
+ machine . state . buttonElement ?. focus ( { preventScroll : true } )
482
482
break
483
483
484
484
case Keys . Tab :
485
485
event . preventDefault ( )
486
486
event . stopPropagation ( )
487
487
flushSync ( ( ) => machine . send ( { type : ActionTypes . CloseMenu } ) )
488
488
focusFrom (
489
- buttonElement ! ,
489
+ machine . state . buttonElement ! ,
490
490
event . shiftKey ? FocusManagementFocus . Previous : FocusManagementFocus . Next
491
491
)
492
492
break
@@ -626,11 +626,10 @@ function ItemFn<TTag extends ElementType = typeof DEFAULT_ITEM_TAG>(
626
626
machine . send ( { type : ActionTypes . CloseMenu } )
627
627
} )
628
628
629
- let buttonElement = useSlice ( machine , ( state ) => state . buttonElement )
630
629
let handleClick = useEvent ( ( event : MouseEvent ) => {
631
630
if ( disabled ) return event . preventDefault ( )
632
631
machine . send ( { type : ActionTypes . CloseMenu } )
633
- restoreFocusIfNecessary ( buttonElement )
632
+ restoreFocusIfNecessary ( machine . state . buttonElement )
634
633
} )
635
634
636
635
let handleFocus = useEvent ( ( ) => {
0 commit comments