Skip to content

Commit b9cc4d4

Browse files
authored
fix(richtext-lexical): error when changing block collapsed state in rare cases (#9421)
1 parent a891e98 commit b9cc4d4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/richtext-lexical/src/features/blocks/client/component/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export const BlockComponent: React.FC<Props> = (props) => {
259259
(changedCollapsed: boolean) => {
260260
void getDocPreferences().then((currentDocPreferences) => {
261261
const currentFieldPreferences =
262-
currentDocPreferences?.fields[parentLexicalRichTextField.name]
262+
currentDocPreferences?.fields?.[parentLexicalRichTextField.name]
263263

264264
const collapsedArray = currentFieldPreferences?.collapsed
265265

packages/richtext-lexical/src/utilities/buildInitialState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export async function buildInitialState({
8888
initialState[id].formState = formStateResult
8989

9090
if (node.type === 'block') {
91-
const currentFieldPreferences = context.preferences?.fields[context.field.name]
91+
const currentFieldPreferences = context.preferences?.fields?.[context.field.name]
9292
const collapsedArray = currentFieldPreferences?.collapsed
9393
if (collapsedArray && collapsedArray.includes(id)) {
9494
initialState[id].collapsed = true

0 commit comments

Comments
 (0)