[lexical-table] Refactor: Call $handleTableSelectionChangeCommand once instead of per-table#8200
Conversation
…nextFocus, shouldCheckSelection introduces TableObservers for global table state (nextFocus, shouldCheckSelection),
…d blocks, and pull table-selection-fixup out
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| ); | ||
| } | ||
| $setSelection(newSelection); | ||
| $addHighlightStyleToTable(editor, tableObserver); |
There was a problem hiding this comment.
Realised that with the $syncTableSelectionState pass happening after all of this, there was no need to explicitly add the styling.
|
Looks like there's a firefox issue here |
…ged selection showing wrong menu) clear selection
| if ($isTableSelection(selection)) { | ||
| const currentSelectionCounts = computeSelectionCount(selection); | ||
| updateSelectionCounts(computeSelectionCount(selection)); | ||
| const isCollapsedTableSelection = selection.anchor.is(selection.focus); |
There was a problem hiding this comment.
If you merge a cell and then enter a single-cell table selection, it would consider the cell mergeable. This just happened to break one of the tests in Firefox because it's easier to set up a single-cell table selection (click, then shift-click a cell - this only works in Firefox).
In the code before, a mergeable cell is not considered un-mergeable so one of the tests was failing in Firefox.
Now:
|
Assuming tests pass on the latest commit, one bug was a silly typo in getAndClearShouldCheckSelectionForTable, another was a selection quirk when unmerging cells, last one was what seemed to be a bug with detecting mergeable/unmergeable table selections in the playground. |
Description
Further refactors the Table's SELECTION_CHANGE_HANDLER ($handleTableSelectionChangeCommand) so that it only needs to run once.
Cheating a bit at the end because there's still some logic that runs over each table, but I think it's preferable to refactor this in pieces.
Key changes:
Note: No existing bugs fixed in this PR but these refactors are a precursor to some important nested table bug fixes.
Test plan
Before
Insert relevant screenshots/recordings/automated-tests
After
Insert relevant screenshots/recordings/automated-tests