Skip to content

Commit 18f6a06

Browse files
committed
feat(ui-drilldown): make Drilldown.Page handle optional Options
INSTUI-4688
1 parent 2e2bd90 commit 18f6a06

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/ui-drilldown/src/Drilldown/DrilldownPage/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import DrilldownSeparator from '../DrilldownSeparator'
3939
import type { OptionChild, SeparatorChild, GroupChild } from '../props'
4040
import { Renderable } from '@instructure/shared-types'
4141

42-
type PageChildren = GroupChild | OptionChild | SeparatorChild
42+
type PageChildren = GroupChild | OptionChild | SeparatorChild | null | false
4343

4444
type DrilldownPageOwnProps = {
4545
id: string

packages/ui-drilldown/src/Drilldown/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,17 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
528528
const childMap = new Map<string, boolean>()
529529

530530
for (const child of children) {
531-
if (!childMap.has(child.props.id)) {
532-
childMap.set(child.props.id, true)
533-
} else {
534-
warn(
535-
false,
536-
`Duplicate id: "${child.props.id}"! Make sure all options have unique ids, otherwise they won't be rendered.`
537-
)
531+
if (child && typeof child === 'object' && child.props?.id) {
532+
if (!childMap.has(child.props.id)) {
533+
childMap.set(child.props.id, true)
534+
} else {
535+
warn(
536+
false,
537+
`Duplicate id: "${child.props.id}"! Make sure all options have unique ids, otherwise they won't be rendered.`
538+
)
538539

539-
return (containsDuplicate = true)
540+
return (containsDuplicate = true)
541+
}
540542
}
541543
}
542544

0 commit comments

Comments
 (0)