From 9bd28dbfb6f5a2bc3ee9ad30d50bd8521ade9b40 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Fri, 20 May 2022 12:06:29 +0200 Subject: [PATCH] fix: give editor focus when the user starts dragging the selection --- src/lib/components/modes/treemode/JSONNode.svelte | 1 + src/lib/components/modes/treemode/TreeMode.svelte | 1 + src/lib/types.js | 1 + 3 files changed, 3 insertions(+) diff --git a/src/lib/components/modes/treemode/JSONNode.svelte b/src/lib/components/modes/treemode/JSONNode.svelte index c3e6a136..de412f86 100644 --- a/src/lib/components/modes/treemode/JSONNode.svelte +++ b/src/lib/components/modes/treemode/JSONNode.svelte @@ -141,6 +141,7 @@ // when left-clicking inside the current selection, do nothing: it can be the start of dragging if (isPathInsideSelection(context.getFullSelection(), path, anchorType)) { if (event.button === 0) { + context.focus() onDragSelectionStart(event) } diff --git a/src/lib/components/modes/treemode/TreeMode.svelte b/src/lib/components/modes/treemode/TreeMode.svelte index 6ac5ce01..6771f041 100644 --- a/src/lib/components/modes/treemode/TreeMode.svelte +++ b/src/lib/components/modes/treemode/TreeMode.svelte @@ -2061,6 +2061,7 @@ getFullState, getFullSelection, findElement, + focus, onPatch: handlePatch, onInsert: handleInsert, onExpand: handleExpand, diff --git a/src/lib/types.js b/src/lib/types.js index 6260a61a..5cf867a5 100644 --- a/src/lib/types.js +++ b/src/lib/types.js @@ -306,6 +306,7 @@ * @property {() => JSON} getFullState * @property {() => Selection} getFullSelection * @property {(path: Path) => Element | null} findElement + * @property {() => void} focus * @property {(operations: JSONPatchDocument, afterPatch?: AfterPatchCallback) => void} onPatch * @property {(type: InsertType) => void} onInsert * @property {(path: Path, expanded: boolean, recursive?: boolean = false) => void} onExpand