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(LexicalNode): fix inline decorator isSelected #5948

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

Conversation

jason89521
Copy link
Contributor

@jason89521 jason89521 commented Apr 24, 2024

Why

I pressed shift + ArrowLeft at the beginning of the video, and then pressed BackSpace to delete the selection. You can see the image node is selected, but when I deleted the selection, it didn't been deleted. Actually, the image node was not selected.

At the second half of the video, I pressed shift + ArrowRight, the first image also showed that it was selected. However, the image node didn't been selected actually, so when I deleted the selection, the image node didn't been deleted.

2024-04-24.1.01.56.mov

What

Beside checking whether the selection is collapsed, we should also check non-collapsed situation.

How

First, check whether the node is an inline decorator node.

Then check whether the anchor is before the focus.

  • If so
    • check whether the anchor at the element node's last offset
    • check whether the anchor's node is the decorator node's parent
    • check whether the decorator node is the last child
    • if the above 3 conditions are satisfied, return false
  • else
    • check whether the focus at the element node's last offset
    • check whether the focus's node is the decorator node's parent
    • check whether the decorator node is the last child
    • if the above 3 conditions are satisfied, return false

Additional Information

After this pr:

2024-04-24.1.20.23.mov

Copy link

vercel bot commented Apr 24, 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 Apr 26, 2024 4:14am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 4:14am

@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 Apr 24, 2024
@jason89521 jason89521 marked this pull request as ready for review April 24, 2024 05:28
@StyleT
Copy link
Contributor

StyleT commented Apr 25, 2024

Hi! Thanks for the contribution!

Can you pls write tests to cover this use case?

@jason89521
Copy link
Contributor Author

@StyleT added in c1d6ada!

@jason89521
Copy link
Contributor Author

@StyleT Hi, just a gentle nudge to see if you could take a moment to review this pull request when you have a chance. Thanks!

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants