Skip to content

Commit

Permalink
[form-builder] PTE: test if node exists before selecting it from focu…
Browse files Browse the repository at this point in the history
…sPath
  • Loading branch information
skogsmaskin authored and rexxars committed Oct 6, 2020
1 parent 4fc3fdc commit 9ded131
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export default function PortableTextInput(props: Props) {
const isChildOnly = isChild && focusPath.length === 3
const isAnnotation = blockSegment && focusPath[1] === 'markDefs'
if ((isBlockOnly || isChildOnly) && !hasFocus) {
const [hasItem] = PortableTextEditor.findByPath(editor, focusPath)
if (hasItem) {
const [node] = PortableTextEditor.findByPath(editor, focusPath)
if (node) {
const point = {path: focusPath, offset: 0}
PortableTextEditor.select(editor, {focus: point, anchor: point})
forceUpdate() // To re-render change-indicators properly
Expand Down Expand Up @@ -129,7 +129,6 @@ export default function PortableTextInput(props: Props) {
}
return
}

// Block focus paths
if (focusPath && ((isChild && focusPath.length > 3) || (!isChild && focusPath.length > 1))) {
let kind = 'blockObject'
Expand Down

0 comments on commit 9ded131

Please sign in to comment.