Skip to content

Commit

Permalink
When creating a new check list, set the checked value of the list i…
Browse files Browse the repository at this point in the history
…tem to `false` instead of `undefined` (facebook#5978)
  • Loading branch information
amanharwara authored and jkjk822 committed Aug 26, 2024
1 parent ac607d5 commit dbb901f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/lexical-list/src/LexicalListItemNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import type {ListNode} from './';
import type {ListNode, ListType} from './';
import type {
BaseSelection,
DOMConversionMap,
Expand Down Expand Up @@ -320,7 +320,14 @@ export class ListItemNode extends ElementNode {
getChecked(): boolean | undefined {
const self = this.getLatest();

return self.__checked;
let listType: ListType | undefined;

const parent = this.getParent();
if ($isListNode(parent)) {
listType = parent.getListType();
}

return listType === 'check' ? Boolean(self.__checked) : undefined;
}

setChecked(checked?: boolean): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-list/src/formatList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export function updateChildrenListItemValue(list: ListNode): void {
if (child.getValue() !== value) {
child.setValue(value);
}
if (isNotChecklist && child.getChecked() != null) {
if (isNotChecklist && child.getLatest().__checked != null) {
child.setChecked(undefined);
}
if (!$isListNode(child.getFirstChild())) {
Expand Down

0 comments on commit dbb901f

Please sign in to comment.