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

fix: delete horizontal node in table cell node #6598

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

keiseiTi
Copy link
Contributor

@keiseiTi keiseiTi commented Sep 5, 2024

Description

fix #6459

This commit solves the problem of continuing to execute subsequent logic when the first node in the ElementNode is decoratorNode

Copy link

vercel bot commented Sep 5, 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 Sep 11, 2024 10:57am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 11, 2024 10:57am

@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 Sep 5, 2024
Copy link

github-actions bot commented Sep 5, 2024

size-limit report 📦

Path Size
lexical - cjs 29.77 KB (0%)
lexical - esm 29.6 KB (0%)
@lexical/rich-text - cjs 38.24 KB (0%)
@lexical/rich-text - esm 31.46 KB (0%)
@lexical/plain-text - cjs 36.82 KB (0%)
@lexical/plain-text - esm 28.86 KB (0%)
@lexical/react - cjs 40.01 KB (0%)
@lexical/react - esm 32.93 KB (0%)

Copy link
Collaborator

@etrepum etrepum left a 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

Comment on lines 1706 to 1711
if ($isElementNode(anchorNode)) {
const childNode = anchorNode.getChildAtIndex(0);
if ($isDecoratorNode(childNode) && anchor.offset === 0) {
return;
}
}
Copy link
Collaborator

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.

Suggested change
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;
}

Comment on lines +1709 to +1710
$isElementNode(anchorNode) &&
$isDecoratorNode(anchorNode.getFirstChild())
Copy link
Collaborator

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

@zurfyx
Copy link
Member

zurfyx commented Sep 11, 2024

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.

@etrepum
Copy link
Collaborator

etrepum commented Sep 12, 2024

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

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
Development

Successfully merging this pull request may close these issues.

Bug: HorizontalRuleNode breaks TableCell in some case
5 participants