UXP, InDesign: WebView postMessage does not work in 20.4
Since version 20.4 of InDesign, sending messages to the WebView element no longer works. Here is a dummy plugin to reproduce the behavior.
https://kdrive.infomaniak.com/app/share/1606376/dbdbc8c1-10c3-4c9a-b4ce-d048fc2864fd
How to test?
Click on the “Send message” button.
Expected behavior?
The message “Hello form panel!” appears in the Webview element (white background).
In InDesign 20.3 it works, from 20.4 no longer.
Why is this important?
This affects the functionality of one of my published plugins.
Code:
Plugin:
const sendMessageButtonElem = document.getElementById("send-message-button");
sendMessageButtonElem?.addEventListener("click", () => {
/* Send message to WebView */
const webviewElem = document.getElementById("webview") ;
webviewElem.postMessage({
"message": "Hello from panel!"
});
});
Webview:
/**
* Window message event listener
* Receive messages from Plugin
*/
window.addEventListener("message", panelMessageHandler);
/**
* Panel message handler
* @param evt
* @returns
*/
async function panelMessageHandler(evt: MessageEvent) {
const webviewMessageOutputElem = document.getElementById("webview-message-output") as HTMLElement;
webviewMessageOutputElem.textContent = evt.data.message;
}
The fix for this issue is available in the InDesign PreRelease build(v21.0.0.184) and above.
Please check if the issue is now resolved.
Download/Update the latest InDesign PreRelease build in Creative Cloud under the “Prerelease” category(Refer to “Prerelease_CreativeCloud.png” for reference)
Please apply to the InDesign PreRelease in case you don’t have access to the InDesign PreRelease build – https://www.adobeprerelease.com/beta/C6DFA254-C40C-4EEB-8F6D-F4AEDA2E6171
If you still encounter any issues, please drop a mail to sharewithID@adobe.com.
—
Adobe InDesign team
-
Roland Dreger
commented
A user has reported a workaround in the Creative Cloud Developer forum. Perhaps this will help to investigate the issue.
»Changing "enableMessageBridge" value to "localAndRemote" fixes the problem: the 2 way communication is restored.«
https://forums.creativeclouddeveloper.com/t/bug-regression-report-ps-26-6-breaks-postmessage-communication-between-the-host-and-local-webview/10824Roland
-
Naina Bhandari
commented
Hi Roland Dreger,
Thank you for reporting this to us. Our team will investigate the issue.
Thanks,
Naina
(Adobe Team)