Skip to content

Commit

Permalink
fix: default page tree selection
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn authored Sep 5, 2021
1 parent cbd2656 commit d4af71c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const PageExplorer: React.FC<PageExplorerProps> = props => {
const [rootItemIds, setRootItemIds] = React.useState(props.rootItemIds)
const [items, setItems] = React.useState(props.items)

const [selectedItem, setSelectedItem] = React.useState<string | null>(
Object.keys(props.items)[0]
const [selectedItem, setSelectedItem] = React.useState<string>(
props.defaultSelection
)

React.useEffect(() => {
Expand Down Expand Up @@ -88,12 +88,12 @@ const PageExplorer: React.FC<PageExplorerProps> = props => {
const values = selectedItem ? getItemValues(selectedItem) : undefined

const handleItemSelect = (id: string | null) => {
setSelectedItem(id)
setSelectedItem(id || props.defaultSelection)
props.onItemSelect(id)
}

const handleItemDelete = (id: string) => {
setSelectedItem(null)
setSelectedItem(props.defaultSelection)

props.onItemDelete(id)
}
Expand Down

0 comments on commit d4af71c

Please sign in to comment.