Skip to content

Commit

Permalink
Add setTimeout for mousemove handler
Browse files Browse the repository at this point in the history
  • Loading branch information
areznik10 committed Apr 18, 2024
1 parent baf4f45 commit 65858b7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/lexical-table/src/LexicalTableSelectionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ export function applyTableHandlers(
};

const onMouseMove = (moveEvent: MouseEvent) => {
const focusCell = getDOMCellFromTarget(moveEvent.target as Node);
if (
focusCell !== null &&
(tableObserver.anchorX !== focusCell.x ||
tableObserver.anchorY !== focusCell.y)
) {
moveEvent.preventDefault();
tableObserver.setFocusCellForSelection(focusCell);
}
setTimeout(() => {
const focusCell = getDOMCellFromTarget(moveEvent.target as Node);
if (
focusCell !== null &&
(tableObserver.anchorX !== focusCell.x ||
tableObserver.anchorY !== focusCell.y)
) {
moveEvent.preventDefault();
tableObserver.setFocusCellForSelection(focusCell);
}
}, 0);
};
return {onMouseMove: onMouseMove, onMouseUp: onMouseUp};
};
Expand Down

0 comments on commit 65858b7

Please sign in to comment.