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-list] Bug Fix: handle non-integer numbers in setIndent #6522

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

jrfitzsimmons
Copy link
Contributor

@jrfitzsimmons jrfitzsimmons commented Aug 15, 2024

Description

Handles non-integer numbers in ListItemNode.setIndent to prevent infinite loop.

Closes #6521

Test plan

Confirmed working in the preview playground, as well as the unit test.

Copy link

vercel bot commented Aug 15, 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 Aug 21, 2024 1:51pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 1:51pm

@facebook-github-bot
Copy link
Contributor

Hi @jrfitzsimmons!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

github-actions bot commented Aug 15, 2024

size-limit report 📦

Path Size
lexical - cjs 29.38 KB (0%)
lexical - esm 29.24 KB (0%)
@lexical/rich-text - cjs 37.74 KB (0%)
@lexical/rich-text - esm 31.05 KB (0%)
@lexical/plain-text - cjs 36.41 KB (0%)
@lexical/plain-text - esm 28.42 KB (0%)
@lexical/react - cjs 39.64 KB (0%)
@lexical/react - esm 32.51 KB (0%)

@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 Aug 15, 2024
@jrfitzsimmons jrfitzsimmons marked this pull request as ready for review August 15, 2024 07:13
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Aug 15, 2024
ivailop7
ivailop7 previously approved these changes Aug 15, 2024
typeof indent === 'number' && indent > -1,
'Invalid indent value.',
);
invariant(typeof indent === 'number', 'Invalid indent value.');
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we need to typecheck here when the type is already guaranteed to be a number by TS. While it is true that types are optional for users I feel like if I were to typecheck everywhere it would add a lot of noise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@acywatson had a similar comment on the PR that added this check (#4120)

Copy link
Collaborator

Choose a reason for hiding this comment

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

The Math.floor is going to guarantee it's a number but it could be NaN so we might still have a bad input bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would still fail the indent >= 0 check. Or are you saying remove the invariant above given the one below will catch non-numbers. My vote would be leave it in as it's more explicit as to what's going on. I.e. not relying on Math.floor to produce NaN and then comparing that to 0. Happy to update if you prefer the latter though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point, I was just looking at it in isolation and not considering both invariants. I think it's fine as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. Is there anything I need to do to fix the extended tests failures? Can't see why this change would cause them to fail...

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: browser lockup when converting paragraph node to list
5 participants