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/utils] Bug Fix: cursor positioning issue with CJK #6947

Closed

Conversation

mrdivyansh
Copy link
Contributor

Description

It fixes #6946. However, I am not sure why TextNode.updateDOM should cause any side-effect.

Closes #6946

Copy link

vercel bot commented Dec 12, 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 Dec 12, 2024 10:27pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 10:27pm

@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 Dec 12, 2024
Copy link

github-actions bot commented Dec 12, 2024

size-limit report 📦

Path Size
lexical - cjs 31.09 KB (0%)
lexical - esm 30.96 KB (0%)
@lexical/rich-text - cjs 40.13 KB (0%)
@lexical/rich-text - esm 32.8 KB (0%)
@lexical/plain-text - cjs 38.71 KB (0%)
@lexical/plain-text - esm 30.12 KB (0%)
@lexical/react - cjs 42.05 KB (0%)
@lexical/react - esm 34.21 KB (0%)

@potatowagon potatowagon added the extended-tests Run extended e2e tests on a PR label Dec 12, 2024
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.

I think you're right that this updateDOM call doesn't really make sense. What updateDOM does is return true if the node should be re-mounted, otherwise it returns false and does some in-place mutations (which is what is likely causing the issues here). If it would've returned true you can detect that because that DOM would be unmounted and createDOM would be called to create a new one so currentAnchorNodeDOM !== previousAnchorNodeDOM would be true. I think the proper fix would be to track those previous DOM variables in the closure outside of the compute function just like previousAnchorNode and previousFocusNode. This way the updateDOM call can be eliminated but the intent of that check can be preserved.

/cc @zurfyx

@etrepum
Copy link
Collaborator

etrepum commented Dec 13, 2024

@mrdivyansh I created a draft PR #6961 with what I think this should look like, but I can't easily repro this bug so if you could take a look that would be great

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: wrong cursor position with CJK keyboard
4 participants