Skip to content

Commit 4913644

Browse files
committed
fix(app-headless-cms): update context state after entry creation
1 parent 65870e6 commit 4913644

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/app-headless-cms/src/admin/components/ContentEntryForm/ContentEntryFormProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const ContentEntryFormProvider = ({
133133
setTimeout(() => {
134134
onAfterCreate(entry);
135135
resolve();
136-
}, 10);
136+
}, 50);
137137
});
138138
}
139139

packages/app-headless-cms/src/admin/components/LexicalCmsEditor/LexicalCmsEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const LexicalCmsEditor = (props: Omit<RichTextEditorProps, "theme">) => {
4040
<LexicalEditor
4141
{...props}
4242
focus={true}
43-
value={JSON.stringify(props.value)}
43+
value={props.value ? JSON.stringify(props.value) : props.value}
4444
onChange={onChange}
4545
staticToolbar={toolbar}
4646
tag={"p"}

packages/app-headless-cms/src/admin/views/contentEntries/ContentEntry/ContentEntryContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ export const ContentEntryProvider = ({
226226
if (response.entry && options?.addItemToListCache) {
227227
addRecordToCache(response.entry);
228228
}
229+
230+
// The `ContentEntryForm` component reads the `entry` from the context, and we want it to have the latest state.
231+
// This way, the form also knows whether it's `pristine` or not.
232+
setEntry(response.entry);
233+
229234
return response;
230235
};
231236

0 commit comments

Comments
 (0)