Views opening in unintended DialogMode

Hi, recently we have encountered an issue where our views are opening up in DialogMode when it is being redirected from an existing DialogWindow.

image
According to this screenshot, this is due to the fact that Jmix has a checking where if this.hasModalDialogWindow() is true, it will force the openMode = DIALOG.

image
Additionally from this screenshot, we found out that when we close a view, it fires the AfterCloseEvent first and then the ViewClosedEvent, which means when I configure to redirect to another view during an AfterCloseEvent, my exising view (a DialogWindow) is still opened hence this.hasModalDialogWindow() = true, forcing my openMode to be DIALOG for whichever view I am redirecting to.

In order to make it work we have to trigger a ViewClosedEvent manually so that this.hasModalDialogWindow() will return false, but its not a very good practice for our coding so could you please have a look into this and fix it?

Hi,

There is no bug from Jmix side. View level event (AfterCloseEvent) should be fired before application level (ViewClosedEvent). To achieve your goal, simple perform redirection after the close() returns the success OperationResult, e.g.:

@Override
public OperationResult close(CloseAction closeAction) {
    return super.close(closeAction)
            .then(() -> viewBuilders.view(this, SandboxView.class)
                    .withOpenMode(ViewOpenMode.NEW_TAB)
                    .open());
}

Regards,
Gleb