Skip to content

fix(ui): guard live preview URL against aborted form-state requests in onSave - #17780

Open
waterWang wants to merge 1 commit into
payloadcms:mainfrom
waterWang:fix/live-preview-abort-17779
Open

fix(ui): guard live preview URL against aborted form-state requests in onSave#17780
waterWang wants to merge 1 commit into
payloadcms:mainfrom
waterWang:fix/live-preview-abort-17779

Conversation

@waterWang

Copy link
Copy Markdown

Description

Fixes #17779

When a save starts while the previous form-state request is still in-flight, the earlier request is aborted and getFormState resolves to { state: null } without a livePreviewURL key. The onSave callback then destructures undefined livePreviewURL and calls setLivePreviewURL(undefined), which silently closes the live preview pane while the user is still typing.

The onChange callback already guards against this with if (!result) { return } — this PR applies the same protection to onSave by only updating the live-preview / preview URLs when the form-state request actually succeeded (i.e. state is present).

Changes

  • packages/ui/src/views/Edit/index.tsx: only call setLivePreviewURL / setPreviewURL when state exists (aborted requests resolve to { state: null })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live preview closes itself mid-edit: aborted form-state request clears livePreviewURL

1 participant