Skip to content

Commit b5d65dd

Browse files
authored
fix(richtext-lexical): next.js multiple refs of same fix (#7572)
Fixes some issue w/ Next.js and passing the same ref multiple times.
1 parent c4ee623 commit b5d65dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/richtext-lexical/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
beforeChangeTraverseFields,
1515
beforeValidateTraverseFields,
1616
deepCopyObject,
17+
deepCopyObjectSimple,
1718
getDependencies,
1819
withNullableJSONSchemaType,
1920
} from 'payload'
@@ -124,13 +125,13 @@ export function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapte
124125
isRoot,
125126
unSanitizedEditorConfig: {
126127
features,
127-
lexical: lexical ? lexical : defaultEditorConfig.lexical,
128+
lexical: lexical ? lexical : deepCopyObjectSimple(defaultEditorConfig.lexical),
128129
},
129130
})
130131

131132
finalSanitizedEditorConfig = {
132133
features: sanitizeServerFeatures(resolvedFeatureMap),
133-
lexical: lexical ? lexical : defaultEditorConfig.lexical,
134+
lexical: lexical ? lexical : deepCopyObjectSimple(defaultEditorConfig.lexical),
134135
resolvedFeatureMap,
135136
}
136137
}
@@ -463,8 +464,8 @@ export function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapte
463464
recurseNodeTree({
464465
nodeIDMap: originalNodeWithLocalesIDMap,
465466
nodes:
466-
(siblingDocWithLocales[field.name] as SerializedEditorState)?.root
467-
?.children ?? [],
467+
(siblingDocWithLocales[field.name] as SerializedEditorState)?.root?.children ??
468+
[],
468469
})
469470
}
470471

0 commit comments

Comments
 (0)