-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixes grid selection to be aware of nested tables #5166
Fixes grid selection to be aware of nested tables #5166
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
A bit on the nit picking side, but if I do 3-level table in table nesting, selection still breaks. |
yeah, wasn't sure if that's something lexical want to support or not, let me see if could generalize it to cover it. |
Actually just tested and works as expected, what it does it basically tries to find common table between 2 cells: lexical.3.tables.in.movWhat it doesn't do - it doesn't handle focus of cells from different tables, so if you have 2 tables next to each other and try to focus beyond single table that would still crash. I wouldn't try to fix it here since it would need more of a product decision, and generally would be more problem of general selection, not table selection. What I'd propose is to add similar "level matching" selection implementation as I've added inside table but for all page to make sure that we are selecting text / paragrpahs / tables as elements, but that would be a product decision maybe closer to Notion selection rather than current Lexical if I'm getting this right. |
Great, however, when I use the / menu and select '5x5 table' and then in any cell I do it again '/' and then '5x5 table' it crashes the selection directly even when using 2 tables nested within each other. |
I cannot reproduce it locally on this branch, could you please share video steps? |
…d-selecting-the-inner-table-is-breaking-the-page
broken_tables.mp4So I managed to replicate the issue, it appears when I use the keyboard arrows to navigate, it happens 50% of the time. If I do point and click, it works fine, but if I navigate with the arrows upon inserting the second table, selection freezes. |
Thanks for the details, was able to replicate now, it seems that selection and grid actions are located in multiple places and not the same for mouse and keyboard events, I'm putting down all possible use cases with keyboard and going to update PR with fixes for all edge cases I could find there. |
Hey @icrosil , is this good for review? I see it working well in the playground preview, but the tests you've added fail often, so unsure if you are planning on more change for this PR. |
Hey I wanted to fix tests first, to make sure I'm not breaking anything, but if that would take too long I'd probably slim them down as functionality now is in better state. I wouldn't claim that it fixed all possible scenarios because of the fragmented selection control I think that would be extremely difficult, but at least we fixed highlighted use cases. Let me try update fixes first, will ping you here on thread when ready for a review. Thanks! |
I've decided to remove flaky tests from diff to see if CI will pass on this, doing more manual checks locally please feel free to review code, especially if CI is green :) |
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.
LGTM
Why
As pointed in #4647 Table selection behaved with issue on moving selection between nested tables. What happened is that we expect nodes anchor/focus (from/to) to be in the same grid by default, but it isn't true for nested tables.
What
Here after finding focus and anchor cells we check if grids for both of them are equal - that would mean we are on the same level, if not we are moving one selection up. This change makes selection behaviour as next:
Before:
lexical.selection.before.mov
After:
lexical.selection.after.mov