-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Fix: Fix issue where selecting a cell then dragging outside of table would not select entire table #6579
Conversation
…ble would not select entire table
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
FYI this test is pretty flakey: https://github.com/facebook/lexical/blob/main/packages/lexical-playground/__tests__/e2e/Tables.spec.mjs#L1307 Running it locally on macOS or Ubuntu 22.04 with In debug I can see that the left frame correctly inserts the image in the second column second row, but on the right frame, it inserts the image in the first column second row. The test flakes even without the changes in this PR and without the changes in #6542. |
@ivailop7 ready for review 🙏 If any suggestions please let me know. |
Will have a look next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it works to me, and all of the test suites are passing
This fixes a regression caused by this PR.
The PR above aimed to solve a destructive issue where triple-clicking in a table could inadvertently select the entire document. The solution caused a regression where dragging out from inside a table wouldn't select the entire table, even though the highlight made it seem like it was selected.
I spent a bit of time trying to fix both the regression and the original triple-click issue but unfortunately had to reach a compromise where I could fix the regression, and fix the triple-click issue, with the compromise that triple-clicking the last cell would end up selecting the first cell (rather than the whole document). That's fine enough for me, so long as the whole document isn't selected, but isn't exactly technically correct.
However I couldn't figure out why the first cell was being selected. The code looks right to me and inspecting the selection before it's made tells me that the last cell should be selected, but for some reason, it's being overriden somewhere to the first cell.
In any case I think this PR represents a suitable compromise and we can either merge it now if it makes sense, or wait to see if someone understands what a fix could look like that addresses both issues.
Test plan
Tests were added and modified. I also added a utility function with the goal of making it easier to read and work with selection objects. Reading other people's selection objects, especially when reviewing the PR, is very hard to contextualize.
For example, this is hard to understand or conceptualize at first glance:
You'd have to print out the DOM to really verify what's going on here as a reviewer.
I've created a helper function that allows for self-describing names:
Not required as part of this PR so I can remove it if it's not helpful.
Before
before.mov
After
after.mov