diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java index 1cc3d4e3bc0..aebe747b803 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -378,10 +378,12 @@ assert getServerId(valueMap) == -1 if (json.hasKey(JsonConstants.UIDL_KEY_EXECUTE)) { // Invoke JS only after all tree changes have been - // propagated - Reactive.addPostFlushListener( - () -> registry.getExecuteJavaScriptProcessor().execute( - json.getArray(JsonConstants.UIDL_KEY_EXECUTE))); + // propagated and in the very end of the browser event loop + Reactive.addPostFlushListener(() -> Scheduler.get() + .scheduleFinally(() -> registry + .getExecuteJavaScriptProcessor() + .execute(json.getArray( + JsonConstants.UIDL_KEY_EXECUTE)))); } Console.log("handleUIDLMessage: "