Introduction
Originally reported as a problem in the pages editor. If the instance is slow enough, you can open e.g. a component dialog multiple times, see MGNLUI-3996 - Getting issue details... STATUS .
Current state
We prevent click after opening a modal dialog via CSS, see ModalityLevel, but this is not solve on the implementation level.
Overlays are stored in the MagnoliaShellState (all apps, sub apps... overlays). It's impossible to get an information which overlay belongs to which app/subapp.
StackTrace
at info.magnolia.ui.vaadin.magnoliashell.MagnoliaShell.addOverlay(MagnoliaShell.java:234)
at info.magnolia.ui.vaadin.magnoliashell.MagnoliaShell.openOverlay(MagnoliaShell.java:203) Shell
at info.magnolia.ui.framework.shell.ShellImpl.openOverlayOnView(ShellImpl.java:221)
at info.magnolia.ui.framework.app.SubAppContextImpl$1.openOverlay(SubAppContextImpl.java:150) Subapp
at info.magnolia.ui.framework.context.AbstractUIContext.openOverlay(AbstractUIContext.java:66)
at info.magnolia.ui.dialog.formdialog.FormDialogPresenterImpl.start(FormDialogPresenterImpl.java:154) Presenter
at info.magnolia.ui.dialog.formdialog.FormDialogPresenterImpl.start(FormDialogPresenterImpl.java:129)
at info.magnolia.personalization.ui.pages.action.EditVariantAction.execute(EditVariantAction.java:91) Edit Component Action
at info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:62)
Possible solutions
Form dialog presenter level
Sub app level
Hold the information about opened modal overlays and prevent opening more overlays until the modal one is closed.
The red error banner in UI. Throws ISE. Maybe this is ok but better would be to get a proper UI message
- most of the methods in the stack trace above don't declare any exception
- we could return null but then we would the check for null in every class up to the action
- we could catch the ISE in the action which is not nice neither thus this would need to be done in every action
Kind of duplication information about opened overlay (MagnoliaShell already holds the information but it's not easy to get the overlays and impossible to get the related overlays only without changing API)
Questions
Prevent opening the duplicated dialogs or just inform the user?
Prevention not possible without an ugly code (null check if every class from the stack trace above or throwing a runtime exception)