Skip to content

Commit b857273

Browse files
fix(richtext-lexical): error in admin panel when block collapsed preference is not an array (#11771)
### What? Got an error in the admin panel when opening a document with richtext and block. The error is: `TypeError: collapsedArray.includes is not a function` Screenshot of the error: ![collapsedArray_includes_error](https://github.com/user-attachments/assets/99c25810-0a10-4d23-a735-127edf7e87d6) After reseting the preferences the error is gone. I did not take a copy of the database before using reset settings, so I'm not sure what the preferences where set to. So not sure how it got that way. ### Why? Make the reading of preferences more robust against wrong data type to avoid error. ### How? Make sure collapsedArray is actually an array before using it as such.
1 parent 90f2491 commit b857273

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function buildInitialState({
9696
if (node.type === 'block') {
9797
const currentFieldPreferences = context.preferences?.fields?.[context.field.name]
9898
const collapsedArray = currentFieldPreferences?.collapsed
99-
if (collapsedArray && collapsedArray.includes(id)) {
99+
if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {
100100
initialState[id].collapsed = true
101101
}
102102
}

0 commit comments

Comments
 (0)