Skip to content

Commit

Permalink
Remove second if
Browse files Browse the repository at this point in the history
the third part takes care of changing selection already. This part also has a bug: the case of selecting table using shift+up (not down) is not handled which makes selection stuck
  • Loading branch information
KatsiarynaDzibrova committed Oct 15, 2024
1 parent 4a8a5cb commit 94421c9
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions packages/lexical-table/src/LexicalTableSelectionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
$isDecoratorNode,
$isElementNode,
$isRangeSelection,
$isRootOrShadowRoot,
$isTextNode,
$setSelection,
COMMAND_PRIORITY_CRITICAL,
Expand Down Expand Up @@ -1454,45 +1453,6 @@ function $handleArrowKey(
$setSelection(newSelection);
stopEvent(event);
return true;
} else if ($isRootOrShadowRoot(focusNode)) {
const selectedNode = selection.getNodes()[0];
if (selectedNode) {
const tableCellNode = $findMatchingParent(
selectedNode,
$isTableCellNode,
);
if (tableCellNode && tableNode.isParentOf(tableCellNode)) {
const firstDescendant = tableNode.getFirstDescendant();
const lastDescendant = tableNode.getLastDescendant();
if (!firstDescendant || !lastDescendant) {
return false;
}
const [firstCellNode] = $getNodeTriplet(firstDescendant);
const [lastCellNode] = $getNodeTriplet(lastDescendant);
const firstCellCoords = tableNode.getCordsFromCellNode(
firstCellNode,
tableObserver.table,
);
const lastCellCoords = tableNode.getCordsFromCellNode(
lastCellNode,
tableObserver.table,
);
const firstCellDOM = tableNode.getDOMCellFromCordsOrThrow(
firstCellCoords.x,
firstCellCoords.y,
tableObserver.table,
);
const lastCellDOM = tableNode.getDOMCellFromCordsOrThrow(
lastCellCoords.x,
lastCellCoords.y,
tableObserver.table,
);
tableObserver.setAnchorCellForSelection(firstCellDOM);
tableObserver.setFocusCellForSelection(lastCellDOM, true);
return true;
}
}
return false;
} else {
let focusParentNode = $findMatchingParent(
focusNode,
Expand Down

0 comments on commit 94421c9

Please sign in to comment.