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

When creating a new check list, set the checked value of the list item to false instead of undefined #5978

Merged
merged 5 commits into from
Aug 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/lexical-list/src/formatList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function insertList(editor: LexicalEditor, listType: ListType): void {

if ($isRootOrShadowRoot(anchorNodeParent)) {
anchorNode.replace(list);
const listItem = $createListItemNode();
const listItem = $createListItemNode(
listType === 'check' ? false : undefined,
);
if ($isElementNode(anchorNode)) {
listItem.setFormat(anchorNode.getFormatType());
listItem.setIndent(anchorNode.getIndent());
Expand Down Expand Up @@ -156,7 +158,9 @@ function createListOrMerge(node: ElementNode, listType: ListType): ListNode {

const previousSibling = node.getPreviousSibling();
const nextSibling = node.getNextSibling();
const listItem = $createListItemNode();
const listItem = $createListItemNode(
listType === 'check' ? false : undefined,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if its more appropriate to make the handling of this behaviour clearer inside packages/lexical-list/src/LexicalListItemNode.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about now? i've refactored LexicalListItemNode.getChecked() to always return a boolean if the parent list type is "check" and undefined otherwise.

listItem.setFormat(node.getFormatType());
listItem.setIndent(node.getIndent());
append(listItem, node.getChildren());
Expand Down
Loading