Skip to content
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

[lexical-table] Bug Fix: Selection in tables with merged cells #6529

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

elbotho
Copy link
Contributor

@elbotho elbotho commented Aug 19, 2024

Description

Quickfix for #6515
As described in the issue currently changing the selection using the arrow keys can throw an error that crashes the editor.
(Error: Uncaught Error: Node at cords not TableCellNode.)

Describe the changes in this pull request

This quickfix works quite well for merged cells at the end of a row (most common cases imo)

For merged cells at the beginning or the middle of a row this simple approach creates some unexpected cursor jumps. But instead of crashing the user can be easily adapt the position and the editor won't break.
(For a full fix the positions would need to consider the colspan everywhere in the table plugin, that would be a bigger refactoring I guess).

I did check where this function is used and did some manual testing and did not encounter unwanted side effects, but this is also my first glance inside the lexical codebase :)
Fingers crossed.

Test plan

Before

before

After

after

Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 6:04am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 6:04am

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 19, 2024
Copy link

github-actions bot commented Aug 19, 2024

size-limit report 📦

Path Size
lexical - cjs 29.38 KB (0%)
lexical - esm 29.24 KB (0%)
@lexical/rich-text - cjs 37.74 KB (0%)
@lexical/rich-text - esm 31.05 KB (0%)
@lexical/plain-text - cjs 36.41 KB (0%)
@lexical/plain-text - esm 28.42 KB (0%)
@lexical/react - cjs 39.64 KB (0%)
@lexical/react - esm 32.51 KB (0%)

@elbotho elbotho marked this pull request as ready for review August 19, 2024 21:57
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Aug 20, 2024
@ivailop7
Copy link
Collaborator

@elbotho thanks for helping out on this. I think the last surface when it comes to table bugs is 'merged cells selection'. If you are motivated to help out clear those issues (all tagged with 'tables') nicely with a better refactor, it would be very welcome.

@elbotho
Copy link
Contributor Author

elbotho commented Aug 20, 2024

@elbotho thanks for helping out on this. I think the last surface when it comes to table bugs is 'merged cells selection'. If you are motivated to help out clear those issues (all tagged with 'tables') nicely with a better refactor, it would be very welcome.

Is this a no to the quickfix?

I see 12 issues with the table tag and around 4-5 seem to relate directly to merged cells and or selection. Are you refering to those?

@ivailop7
Copy link
Collaborator

ivailop7 commented Aug 20, 2024

@elbotho thanks for helping out on this. I think the last surface when it comes to table bugs is 'merged cells selection'. If you are motivated to help out clear those issues (all tagged with 'tables') nicely with a better refactor, it would be very welcome.

Is this a no to the quickfix?

I see 12 issues with the table tag and around 4-5 seem to relate directly to merged cells and or selection. Are you refering to those?

I'm OK to merge this PR, despite the lack of tests, since it doesn't seem to make things worse, but it would be nice to have a proper fix, even if it takes longer. Yes, I'm refering to those 4-5 issues that are all the same issue essentially.

@ivailop7 ivailop7 added this pull request to the merge queue Aug 21, 2024
Merged via the queue into facebook:main with commit 0373248 Aug 21, 2024
41 checks passed
@elbotho
Copy link
Contributor Author

elbotho commented Aug 21, 2024

Thank you @ivailop7!
I'll try to find some time for a proper refactor with additional test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR
Projects
None yet
6 participants