DialogWindow too eager

MacOS 10.15.6

I have a DialogWindow created like this:

DialogWindow::LaunchOptions o;

o.content.setOwned (new RegistrationComponent());
o.content->setSize (500, 340);

o.dialogTitle = “Window name”;
o.dialogBackgroundColour = Colours::white;
o.escapeKeyTriggersCloseButton = true;
o.useNativeTitleBar = true;
o.resizable = false;

registrationDialog = o.launchAsync();

The window is a modal on top of the main app. It contains a button which launches a url in the browser using URL::launchInDefaultBrowser().

Scenario 1:

  • App on desktop (i.e. not full-screen).
  • Browser currently open (on desktop, i.e. not full-screen).
  • Click url button.
    Result: Dialog disappears, link opens in new tab, then dialog immediately reappears on top.
    Expected: Dialog should not reappear. It should sit underneath the browser.

Scenario 2:

  • App on desktop (i.e. not full-screen).
  • Other applications currently open (on desktop, i.e. not full-screen, underneath my app).
  • Click on another open application.
    Result: Main app disappears under other app, dialog does not disappear and stays on top, focus shifts to other application.
    Expected: Main app and dialog disappear underneath clicked app.

Question:
Is there any way to force the expected behaviour in each scenario?