Skip to content

Commit

Permalink
fix: shift-click to select multiple items broken
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Jan 8, 2022
1 parent a3c8021 commit a28bbdf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/components/modes/treemode/JSONNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
export let onExpandSection
export let selection
export let getFullSelection
// TODO: it is ugly to have to translate selection into selectionObj, and not accidentally use the wrong one. Is there an other way?
$: selectionObj = selection && selection[STATE_SELECTION]
Expand Down Expand Up @@ -139,11 +140,14 @@
if (event.shiftKey) {
// Shift+Click will select multiple entries
onSelect({
type: SELECTION_TYPE.MULTI,
anchorPath: selectionObj.anchorPath,
focusPath: path
})
const fullSelection = getFullSelection()
if (fullSelection) {
onSelect({
type: SELECTION_TYPE.MULTI,
anchorPath: fullSelection.anchorPath,
focusPath: path
})
}
} else {
switch (anchorType) {
case SELECTION_TYPE.KEY:
Expand Down Expand Up @@ -366,6 +370,7 @@
: undefined}
{readOnly}
{normalization}
{getFullSelection}
{onPatch}
{onInsert}
{onExpand}
Expand Down Expand Up @@ -490,6 +495,7 @@
validationErrors={validationErrors ? validationErrors[key] : undefined}
{readOnly}
{normalization}
{getFullSelection}
{onPatch}
{onInsert}
{onExpand}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1900,6 +1900,10 @@
}
}
function getFullSelection() {
return selection
}
$: autoScrollHandler = createAutoScrollHandler(refContents)
</script>

Expand Down Expand Up @@ -1986,6 +1990,7 @@
{validationErrors}
{readOnly}
{normalization}
{getFullSelection}
onPatch={handlePatch}
onInsert={handleInsert}
onExpand={handleExpand}
Expand Down

0 comments on commit a28bbdf

Please sign in to comment.