@@ -893,7 +893,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
893893 // Use action ID if exists, otherwise first non-action option's ID
894894 const targetId = actionLabel
895895 ? this . _headerActionId
896- : this . currentPage . children [ 0 ] ?. props . id
896+ : this . getFirstOption ( ) ?. props . id
897897 setTimeout ( ( ) => {
898898 this . setState ( {
899899 highlightedOptionId : targetId
@@ -911,6 +911,24 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
911911 }
912912 }
913913
914+ getFirstOption = ( ) => {
915+ const children = Children . toArray ( this . currentPage ?. children )
916+
917+ const child = children [ 0 ]
918+ if ( ! child ) return undefined
919+
920+ // If it's a regular option, return it
921+ if ( matchComponentTypes < OptionChild > ( child , [ DrilldownOption ] ) ) {
922+ return child
923+ }
924+ // If it's a group, get its options
925+ if ( matchComponentTypes < GroupChild > ( child , [ Drilldown . Group ] ) ) {
926+ const groupOptions = Children . toArray ( child . props . children )
927+ return groupOptions [ 0 ] as OptionChild
928+ }
929+ return undefined
930+ }
931+
914932 renderList (
915933 getOptionProps : SelectableRender [ 'getOptionProps' ] ,
916934 getDisabledOptionProps : SelectableRender [ 'getDisabledOptionProps' ]
@@ -1512,7 +1530,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
15121530 // Use action ID if exists, otherwise first non-action option's ID
15131531 const targetId = actionLabel
15141532 ? this . _headerActionId
1515- : this . currentPage . children [ 0 ] ?. props . id
1533+ : this . getFirstOption ( ) ?. props . id
15161534
15171535 if ( ! targetId ) return null
15181536 return this . _popover ?. _contentElement ?. querySelector (
0 commit comments