Skip to content

Commit 67fa5a0

Browse files
authored
fix(live-preview): foreign postMessage events reset client-side state (#12925)
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. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210628466702818
1 parent bcb10b5 commit 67fa5a0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/live-preview/src/handleMessage.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,9 @@ export const handleMessage = async <T extends Record<string, any>>(args: {
6767
returnmergedData
6868
}
6969

70-
returninitialData
70+
if(!_payloadLivePreview.previousData){
71+
_payloadLivePreview.previousData=initialData
72+
}
73+
74+
return_payloadLivePreview.previousDataasT
7175
}

0 commit comments

Comments
 (0)