Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions packages/ui-drilldown/src/Drilldown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
// Use action ID if exists, otherwise first non-action option's ID
const targetId = actionLabel
? this._headerActionId
: this.currentPage.children[0]?.props.id
: this.getFirstOption()?.props.id
setTimeout(() => {
this.setState({
highlightedOptionId: targetId
Expand All @@ -911,6 +911,24 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
}
}

getFirstOption = () => {
const children = Children.toArray(this.currentPage?.children)

const child = children[0]
if (!child) return undefined

// If it's a regular option, return it
if (matchComponentTypes<OptionChild>(child, [DrilldownOption])) {
return child
}
// If it's a group, get its options
if (matchComponentTypes<GroupChild>(child, [Drilldown.Group])) {
const groupOptions = Children.toArray(child.props.children)
return groupOptions[0] as OptionChild
}
return undefined
}

renderList(
getOptionProps: SelectableRender['getOptionProps'],
getDisabledOptionProps: SelectableRender['getDisabledOptionProps']
Expand Down Expand Up @@ -1512,7 +1530,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
// Use action ID if exists, otherwise first non-action option's ID
const targetId = actionLabel
? this._headerActionId
: this.currentPage.children[0]?.props.id
: this.getFirstOption()?.props.id

if (!targetId) return null
return this._popover?._contentElement?.querySelector(
Expand Down
Loading