-
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
fix: delete horizontal node in table cell node #6598
base: main
Are you sure you want to change the base?
fix: delete horizontal node in table cell node #6598
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
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.
It would be great to have a test that demonstrates that this does fix it
if ($isElementNode(anchorNode)) { | ||
const childNode = anchorNode.getChildAtIndex(0); | ||
if ($isDecoratorNode(childNode) && anchor.offset === 0) { | ||
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.
I'd probably re-order this to short-circuit with fewer function calls, e.g.
if ($isElementNode(anchorNode)) { | |
const childNode = anchorNode.getChildAtIndex(0); | |
if ($isDecoratorNode(childNode) && anchor.offset === 0) { | |
return; | |
} | |
} | |
if (anchor.offset === 0 && $isElementNode(anchorNode) && $isDecoratorNode(anchorNode.getFirstChild())) { | |
return; | |
} |
$isElementNode(anchorNode) && | ||
$isDecoratorNode(anchorNode.getFirstChild()) |
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.
I think the best solution is probably $isRootOrShadowRoot(anchorNode)
? It would be nice to add a test and maybe a comment around here to describe what we're trying to do here
Thank you, can you expand on the problem? I believe there's an issue with selection and shadow root, backspace should never see beyond a shadow root. However, the horizontal line appears to be deletable as intended. |
The problem is that the decorator logic doesn't check for a shadow root. When you delete the paragraph before the HR, put the selection there (offset 0 of the TableCellNode), delete again it ends up deleting the TableCellNode when the expected behavior would be a no-op |
Description
fix #6459
This commit solves the problem of continuing to execute subsequent logic when the first node in the ElementNode is decoratorNode