Skip to content

fix(live-preview): foreign postMessage events reset client-side state - #12925

Merged
jacobsfletch merged 1 commit into
mainfrom
fix/live-preview-message-handler
Jun 26, 2025
Merged

jacobsfletch merged 1 commit into
mainfrom
fix/live-preview-message-handler

Conversation

@jacobsfletch

@jacobsfletch jacobsfletch commented Jun 24, 2025 •

Copy link
Copy Markdown
Member

Fixes #10654. Needed for #12860.

If the admin panel broadcasts foreign postMessage events, i.e. those without the payload-live-preview signature, client-side live preview subscriptions will reset back to initial state.

This is because we dispatch two postMessage events in the admin panel, one for client-side live preview to catch (payload-live-preview), and the other for server-side live preview (payload-document-event). This was not previously noticeable because both events would only get called simultaneously on initial render, where initial state is already the expected result.

Now that Live Preview can be freely toggled on and off, both events are frequently dispatched and very obviously disregard the current working state.


@jacobsfletch
jacobsfletch merged commit 67fa5a0 into main Jun 26, 2025
@jacobsfletch
jacobsfletch deleted the fix/live-preview-message-handler branch June 26, 2025 18:05
@github-actions

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.44.0

@PeteJStewart

Copy link
Copy Markdown

I had experience this issue with the Svelte live preview package I wrote, but had assumed it was a glitch in the way I wrote it.
I created a fix in the package, but wasn't totally happy with it, so I'm pleased to see this was actually a bug in live preview that has now been resolved! 🥳

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client livepreview callback

2 participants