From 926fe1ade28445d99f8b45490b3c9cfb542268e0 Mon Sep 17 00:00:00 2001 From: egwoo Date: Wed, 2 Feb 2022 23:43:06 -0600 Subject: [PATCH] Return pos if descObj.parent is null In the example at https://tiptap.dev/api/nodes/task-item if you try to click the checkbox to toggle the todo item, you get a console error message: ``` Uncaught RangeError: Index 1 out of range for at F.child (vendor.248662a3.js:5:26763) at F.findIndex (vendor.248662a3.js:5:27448) at Me.nodeAt (vendor.248662a3.js:5:40931) at index.8f971c3d.js:1:2515 at tabindex.0101c1e1.js:3:1741 at Object.command (tabindex.0101c1e1.js:3:24344) at HTMLInputElement. (index.8f971c3d.js:1:2476) ``` Looking into this, it looks like descObj exists, but descObj.parent is null, so the function returns nothing. When I changed the return value to `pos`, it started working again. --- src/viewdesc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/viewdesc.js b/src/viewdesc.js index 1653d531..25fce7e3 100644 --- a/src/viewdesc.js +++ b/src/viewdesc.js @@ -637,6 +637,7 @@ class NodeViewDesc extends ViewDesc { // own position) if (!descObj) return pos if (descObj.parent) return descObj.parent.posBeforeChild(descObj) + return pos }, outerDeco, innerDeco) let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM