-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug Fix : fix cursor looping and incorrect paragraph insertion after tables #8030
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
base: main
Are you sure you want to change the base?
Conversation
…e $createParagraphNode
Removed unnecessary checks and code related to text node styles.
Table selection issue
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
left a comment
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.
This isn't a complete workaround and it does not add any tests to show that it works as expected
| const elementBefore = | ||
| anchorNode.__prev && $getNodeByKey(anchorNode.__prev); |
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.
This is better written as anchorNode.getPreviousSibling()
| if (elementBefore && elementBefore.__type === 'table') { | ||
| return; | ||
| } |
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.
This is not an acceptable solution because LexicalSelection shouldn't know about tables and the type of a table could be any string (in situations where a node override is used to replace TableNode with a subclass)
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.
How can we identify the paragraph node which is just after the table in hierarchy other than the above method ?
If we recognize it then we can prevent deletion of it which resolves the bug.
Description
This PR fixes an issue where cursor navigation becomes inconsistent when a table is the final block in the document.
Fixes #7999
Problem
When a table is the last node and all content after it is deleted:
This makes it difficult for users to understand how to add content after a table.
Cause
When there is no text in the direction of navigation, Lexical attempts to explore adjacent nodes. If the previous node is a table, this logic re-enters table selection and causes the cursor to cycle back into the table.
Fix
Short-circuit navigation/deletion logic when:
This prevents Lexical from re-entering table selection logic and allows the cursor to correctly move and remain below the table.
Result
Impact
Primarily a polish improvement, but significantly improves usability and prevents user confusion when editing content after tables.