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: #5974 Cursor jump to the end of the document when a collaborator deletes focusing paragraph #5975

Conversation

matsuyama-k1
Copy link
Contributor

fixed #5974

Screen.Recording.2024-04-27.at.16.41.24.mov

Copy link

vercel bot commented Apr 27, 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 May 15, 2024 10:51am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2024 10:51am

@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 27, 2024
@ivailop7
Copy link
Collaborator

@fantactuka could you look into this one, would really like to land this one before the next release.

}

// retrieve the parent paragraph node for the currently selected node
const selectedParagraphNode = $findParentParagraphNode(
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 you can reuse:

const selectedParagraphNode = $findMatchingParent(selectedNode, (node) => $isParagraphNode(node));

Validate that it's the behaviour you are after - get the closest paragraph parent to 'selectedNode'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@StyleT
Copy link
Contributor

StyleT commented Apr 29, 2024

This is great! Can you pls add a test for this fix? To prevent regression

}

const prevParagraphNode = $getNodeByKey(prevParagraphNodeKey);
if (prevParagraphNodeKey in currentParagraphKeys && prevParagraphNode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As currentParagraphKeys is an array, it should probably be includes() not in

Suggested change
if (prevParagraphNodeKey in currentParagraphKeys && prevParagraphNode) {
if (currentParagraphKeys .includes(prevParagraphNodeKey) && prevParagraphNode) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@matsuyama-k1
Copy link
Contributor Author

matsuyama-k1 commented May 7, 2024

I added a test and fixed!
It looks like integrity test is failed because Collaboration.test.ts is not completely typed.

@matsuyama-k1
Copy link
Contributor Author

matsuyama-k1 commented May 15, 2024

The pull request that almost same with my code was created and passed....😢
It was any mention for my PR or issue despite mentioning other issues.

is it ok in Lexilcal community?

mine
https://github.com/facebook/lexical/pull/5975/files#diff-3d291634235852090f5aa491928d6d43fa366302bf0222b0629adf3580e64ab2R549

other's
https://github.com/facebook/lexical/pull/6070/files#diff-3d291634235852090f5aa491928d6d43fa366302bf0222b0629adf3580e64ab2R552

@ivailop7
Copy link
Collaborator

A more generic fix was merged here: b5fa87d

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.

Bug: Cursor jump to the end of the document when a collaborator deletes focusing paragraph
5 participants