Skip to content

Commit

Permalink
[desk-tool] Fix error when duplicating document in fallback edit pane (
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Jun 20, 2019
1 parent a9372e3 commit 751a2ae
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packages/@sanity/desk-tool/src/pane/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,22 @@ export default withRouterHOC(

this.duplicate$ = documentStore.create(duplicatedDocument).subscribe(copied => {
const copyDocId = getPublishedId(copied._id)
const newPanes = router.state.panes.map((prev, i) =>
i === paneIndex - 1 && prev === prevId ? copyDocId : prev
)
router.navigate({
...router.state,
panes: newPanes
})
if (router.state.panes) {
const newPanes = router.state.panes.map((prev, i) =>
i === paneIndex - 1 && prev === prevId ? copyDocId : prev
)
router.navigate({
...router.state,
panes: newPanes
})
} else if (router.state.editDocumentId) {
router.navigate({
...router.state,
editDocumentId: copyDocId
})
} else {
throw new Error('Unknown router state')
}
})
}

Expand Down

0 comments on commit 751a2ae

Please sign in to comment.