[lexical-table] Refactor: use monolithic listener for table SELECTION_CHANGE_COMMAND and deselection handler#8187
Merged
etrepum merged 8 commits intofacebook:mainfrom Mar 4, 2026
Conversation
…ablePluginHelpers
…ble when deselecting tables
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Mar 3, 2026
Collaborator
etrepum
left a comment
There was a problem hiding this comment.
I've only done a quick look at the code here and it seems good, but it might make sense to explicitly add some test coverage to make sure the multi-table (and nested-table?) scenarios work as expected? I don't know what our current coverage of that looks like.
Contributor
Author
|
I'll add more multi-table coverage. The nested table scenarios are not well tested, because the current behaviour (when using the mouse) is frankly quite broken, with seemingly nondeterministic outcomes. I tried to add some tests for that in #8107 but I feel like it would now be better to include new nested table tests alongside the a more stable selection handler. |
etrepum
approved these changes
Mar 4, 2026
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
As discussed in #8107 the SELECTION_CHANGE_COMMAND and various pointer events are registered for each table in
applyTableHandler. There is also a lot of recursive updates going on. It would be better to have a monolithic handler that handles table selection events, as it makes it far easier to reason about what is happening when you have nested tables.This PR tackles some low hanging fruit:
registerTableSelectionObserver(i.e. only once). It still runs the old logic ($handleTableSelectionChangeCommand) on each table in sequence thoughpointerDownCallback, which handles clearing table highlight selections, is similarly hoisted up.Next up is a refactor of
$handleTableSelectionChangeCommandso that it just runs once and behaves as expected across all the tables.Test plan
Before
N/A, this is a refactor
After
N/A no behaviour changes, all tests passing