[lexical-table] Bug Fix: handle table selections crossing into/out of nested tables#8234
Merged
etrepum merged 3 commits intofacebook:mainfrom Mar 19, 2026
Merged
Conversation
… nested table drag-selections that cross tables
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
New tests failing in Firefox, investigating. Seems like on Firefox, a shift-click selection into or out of a nested table selects more than the user requested, but not for top-level tables. Screen.Recording.2026-03-18.at.5.56.28.pm.movEDIT: Ended up disabling these tests on Firefox, because this is what was happening before (above video is from live Playground), and I would rather not let perfect get in the way of good. |
randal-atticus
commented
Mar 18, 2026
| tableObservers: TableObservers, | ||
| ) { | ||
| const prevSelection = $getPreviousSelection(); | ||
| if ($isRangeSelection(selection)) { |
Contributor
Author
There was a problem hiding this comment.
selection was already a RangeSelection. Unfortunately, this bloated the diff, but reviewing without whitespace changes makes this more legible
etrepum
approved these changes
Mar 19, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Further improvements to table selections, and specifically fixing a nested table selection case.
$fixRangeSelectionForSelectedTablenow only runs once (instead of once per table), in line with previous refactors to avoid running all the logic across every table, thereby making it hard to handle nested tables.The logic has been updated to correctly handle Range Selections that cross into/out of a nested table. Just as before, the (anchor OR focus) is shifted to the (start OR end) of the (anchor OR focus) table depending on the direction of the selection.
Added Playground tests to assert behaviour for nested and non-nested tables.
Test plan
Before
On Playground, observe that range selections crossing a nested table will erroneously expand to the outer table.
Screen.Recording.2026-03-18.at.5.58.12.pm.mov
After
As of this PR, range selections crossing a nested table no longer expand to the outer table.
Screen.Recording.2026-03-18.at.5.58.41.pm.mov
(Just noticed the "table selection" on the inner table is a bit too sticky, but that's a separate bug)