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

Clone objects from the CSS cache before mutating them #3945

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

birtles
Copy link
Contributor

@birtles birtles commented Feb 20, 2023

Fixes #3944.

This patch also fixes a bug in $getSelectionStyleValueForProperty that
was papered over by this bug--namely that when it is called on
a collapsed selection we should report the style on the selection
regardless of whether it agrees with the current node style.

@vercel
Copy link

vercel bot commented Feb 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
lexical ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 4:29AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 21, 2023 at 4:29AM (UTC)

@birtles
Copy link
Contributor Author

birtles commented Feb 20, 2023

After posting this, I was thinking I might try to drop the change to $isTextNode and try adding a Readonly<> annotation to the result of getStyleObjectFromCSS to catch bugs like this earlier.

Fixes facebook#3944.

This patch also fixes a bug in $getSelectionStyleValueForProperty that
was papered over by this bug--namely that when it is called on
a collapsed selection we should report the style on the selection
regardless of whether it agrees with the current node style.
@birtles
Copy link
Contributor Author

birtles commented Feb 21, 2023

This is ready for review now.

I reverted the change to $isTextNode since, if we change the $isXXXNode helpers to take an unknown input, we should probably change all of them at the same time.

Also, I haven't updated the return type of getStyleObjectFromCSS to Readonly<> yet because it turns out that function is exported so doing so is a potentially breaking change which should probably be made separately. I'll file a separate issue for that.

Copy link
Contributor

@thegreatercurve thegreatercurve left a comment

Choose a reason for hiding this comment

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

LGTM, but can we make one change to avoid having to ship this as a breaking change.

@thegreatercurve thegreatercurve merged commit dd920e0 into facebook:main Feb 22, 2023
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: When setting styles on a collapsed selection, the styles object is not copied.
3 participants