diff --git a/.changeset/neat-pets-grow.md b/.changeset/neat-pets-grow.md new file mode 100644 index 000000000..b3f8ba098 --- /dev/null +++ b/.changeset/neat-pets-grow.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fix tripple click handling in nested blocks diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 509228978..c0c8376c7 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -780,9 +780,17 @@ export const Editable = (props: EditableProps) => { } if (event.detail === TRIPLE_CLICK && path.length >= 1) { - const start = Editor.start(editor, [path[0]]) - const end = Editor.end(editor, [path[0]]) - const range = Editor.range(editor, start, end) + let blockPath = path + if (!Editor.isBlock(editor, node)) { + const block = Editor.above(editor, { + match: n => Editor.isBlock(editor, n), + at: path, + }) + + blockPath = block?.[1] ?? path.slice(0, 1) + } + + const range = Editor.range(editor, blockPath) Transforms.select(editor, range) return }