@@ -889,7 +889,14 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
889889 handleToggle = ( event : React . UIEvent | React . FocusEvent , shown : boolean ) => {
890890 const { onToggle } = this . props
891891
892- this . setState ( { isShowingPopover : shown } )
892+ const mouseEvent = event as React . MouseEvent
893+
894+ this . setState ( { isShowingPopover : shown } , ( ) => {
895+ // Focus first item when it's a keyboard event (mouseEvent.detail === 0)
896+ if ( mouseEvent . detail === 0 && shown ) {
897+ this . focusFirstAvailableItem ( )
898+ }
899+ } )
893900
894901 if ( typeof onToggle === 'function' ) {
895902 onToggle ( event , {
@@ -900,6 +907,24 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
900907 }
901908 }
902909
910+ focusFirstAvailableItem ( ) {
911+ if ( ! this . currentPage ) return
912+
913+ // Check for action option
914+ const actionLabel = callRenderProp ( this . currentPage . renderActionLabel )
915+ // Use action ID if exists, otherwise first non-action option's ID
916+ const targetId = actionLabel
917+ ? this . _headerActionId
918+ : this . currentPage . children [ 0 ] ?. props . id
919+
920+ if ( ! targetId ) return
921+
922+ this . setState ( { highlightedOptionId : targetId } , ( ) => {
923+ // A slight delay is needed to focus the first item after the popover appears.
924+ setTimeout ( ( ) => this . focusOption ( targetId ) , 10 )
925+ } )
926+ }
927+
903928 renderList (
904929 getOptionProps : SelectableRender [ 'getOptionProps' ] ,
905930 getDisabledOptionProps : SelectableRender [ 'getDisabledOptionProps' ]
@@ -1055,7 +1080,8 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
10551080 role,
10561081 elementRef,
10571082 variant : 'default' ,
1058- tabIndex : - 1
1083+ // header should not get focused (role === 'presentation')
1084+ tabIndex : role === 'presentation' ? - 1 : 0
10591085 }
10601086
10611087 // extra data we need track on the option,
@@ -1378,7 +1404,6 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
13781404 borderWidth = "small"
13791405 as = "div"
13801406 elementRef = { this . handleDrilldownRef }
1381- tabIndex = { 0 }
13821407 css = { styles ?. drilldown }
13831408 position = "relative"
13841409 borderRadius = "small"
@@ -1481,7 +1506,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
14811506 this . handleToggle ( event , false )
14821507 } }
14831508 onShowContent = { ( event ) => this . handleToggle ( event , true ) }
1484- mountNode = { mountNode }
1509+ mountNode = { mountNode || this . ref }
14851510 placement = { placement }
14861511 withArrow = { withArrow }
14871512 positionTarget = { positionTarget }
0 commit comments