Skip to content

Commit

Permalink
fix: sometimes multiple cells selected in Table mode
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Aug 30, 2023
1 parent 30627f2 commit c7705f6
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/lib/components/modes/tablemode/TableMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
isEditingSelection,
isValueSelection,
pathInSelection,
pathStartsWith,
removeEditModeFromSelection
} from '$lib/logic/selection.js'
import { createHistory } from '$lib/logic/history.js'
Expand Down Expand Up @@ -429,21 +430,7 @@
if (!isEqual(documentState.selection, externalSelection)) {
debug('applyExternalSelection', externalSelection)
if (externalSelection === null) {
updateSelection(externalSelection)
}
if (isValueSelection(externalSelection)) {
// check whether the selection is a leaf, and not an object (that would select multiple cells)
const value = getIn(json, externalSelection.path)
if (isObjectOrArray(value)) {
return
}
updateSelection(externalSelection)
}
// we ignore other selection types like key or inline
updateSelection(externalSelection)
}
}
Expand Down Expand Up @@ -1791,13 +1778,14 @@
{#each columns as column, columnIndex}
{@const path = [String(rowIndex)].concat(column)}
{@const value = getIn(item, column)}
{@const isSelected = pathInSelection(json, documentState.selection, path)}
{@const isSelected =
isValueSelection(documentState.selection) &&
pathStartsWith(documentState.selection.path, path)}
{@const validationErrorsByColumn = validationErrorsByRow?.columns[columnIndex]}
<td
class="jse-table-cell"
data-path={encodeDataPath(path)}
class:jse-selected-value={isSelected &&
isValueSelection(documentState.selection)}
class:jse-selected-value={isSelected}
>
{#if isObjectOrArray(value)}
<InlineValue
Expand Down

0 comments on commit c7705f6

Please sign in to comment.