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: Prevent error when calling formatList when selection is at root #6994

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amanharwara
Copy link
Contributor

Description

Currently, if the selection is at the root and you toggle one of the list options, it throws an error Error: replace: cannot be called on root nodes.

This PR fixes this by selecting the first child of the root if available, or creating a new paragraph, appending and selecting it before re-running the insertList function.

Before

root-node-replace-before-fix.mov

After

root-node-replace-after-fix.mov

Copy link

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

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

size-limit report 📦

Path Size
lexical - cjs 31.21 KB (0%)
lexical - esm 31.1 KB (0%)
@lexical/rich-text - cjs 40.31 KB (0%)
@lexical/rich-text - esm 33.01 KB (0%)
@lexical/plain-text - cjs 38.85 KB (0%)
@lexical/plain-text - esm 30.22 KB (0%)
@lexical/react - cjs 42.13 KB (0%)
@lexical/react - esm 34.26 KB (0%)

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.

2 participants