UI is unresponsive after invoking navigate and displaying a modal dialog
Describe the bug
Calling UI.navigate(MyRoute.class) and opening a modal dialog in the beforeEnter hook results in an unresponsive UI. For example, the loading indicator keeps blinking indefinitely. This issue seems to occur because the modal dialog blocks the navigation lifecycle, preventing the UI from completing the transition. Without the modal, navigation proceeds normally.
Expected-behavior
With/Without the modal, navigation should be proceed normally.
Reproduction
Call a Route with UI.navigate(MyRoute.class) on MyRoute.class call
@Override
public void beforeEnter(BeforeEnterEvent event) {
Dialog dialog = new Dialog();
dialog.add(new Label());
dialog.setCloseOnOutsideClick(true);
dialog.setModal(true);
dialog.open();
super.beforeEnter(event);
}
MyRoute.class contains an image and uses the new DownloadHandler as a resource, since StreamResourceApi is deprecated. However, when a modal dialog is opened, the resource fails to load (HTTP 302). This redirect triggers the StreamRequestHandler, which then returns a 403 error.
System Info
Vaadin 24.8.2, 24.8.3 Jetty 12.0.23
Workaround from vaadin prime support
getElement().executeJs("return").then(x->dialog.open());
I can confirm that works and we use this until a bugfix is available.
Move your dialog to afterNavigation or below the super call.
@knoobie this doesn't work. On prime support chat we explored all possible options, including other potential events. The last statement was that this particular case was not considered and that it is a bug.
Workaround from vaadin prime support
getElement().executeJs("return").then(x->dialog.open());I can confirm that works and we use this until a bugfix is available.
Note: If you're using the vcf-pdf-viewer => with this workaround, loading via the DownloadHandler API does not work initially. The viewer remains empty. "The workaround for the workaround" is getElement().executeJs("return").then(x -> pdfView.setSrc(res.value()));
Is there someone on vaadin to fix this bug or give a statement? Thanks! 😊