Skip to content

Commit c7705f6

Browse files
committedAug 30, 2023
fix: sometimes multiple cells selected in Table mode
1 parent 30627f2 commit c7705f6

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed
 

‎src/lib/components/modes/tablemode/TableMode.svelte

+6-18
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
isEditingSelection,
9292
isValueSelection,
9393
pathInSelection,
94+
pathStartsWith,
9495
removeEditModeFromSelection
9596
} from '$lib/logic/selection.js'
9697
import { createHistory } from '$lib/logic/history.js'
@@ -429,21 +430,7 @@
429430
if (!isEqual(documentState.selection, externalSelection)) {
430431
debug('applyExternalSelection', externalSelection)
431432
432-
if (externalSelection === null) {
433-
updateSelection(externalSelection)
434-
}
435-
436-
if (isValueSelection(externalSelection)) {
437-
// check whether the selection is a leaf, and not an object (that would select multiple cells)
438-
const value = getIn(json, externalSelection.path)
439-
if (isObjectOrArray(value)) {
440-
return
441-
}
442-
443-
updateSelection(externalSelection)
444-
}
445-
446-
// we ignore other selection types like key or inline
433+
updateSelection(externalSelection)
447434
}
448435
}
449436
@@ -1791,13 +1778,14 @@
17911778
{#each columns as column, columnIndex}
17921779
{@const path = [String(rowIndex)].concat(column)}
17931780
{@const value = getIn(item, column)}
1794-
{@const isSelected = pathInSelection(json, documentState.selection, path)}
1781+
{@const isSelected =
1782+
isValueSelection(documentState.selection) &&
1783+
pathStartsWith(documentState.selection.path, path)}
17951784
{@const validationErrorsByColumn = validationErrorsByRow?.columns[columnIndex]}
17961785
<td
17971786
class="jse-table-cell"
17981787
data-path={encodeDataPath(path)}
1799-
class:jse-selected-value={isSelected &&
1800-
isValueSelection(documentState.selection)}
1788+
class:jse-selected-value={isSelected}
18011789
>
18021790
{#if isObjectOrArray(value)}
18031791
<InlineValue

0 commit comments

Comments
 (0)
Please sign in to comment.