Dialog: Fix stacking of modal dialog overlays

Fixes #10138

There's an existing visual test which actually covers this really well: `/tests/visual/dialog/complex-dialogs.html`
shouldn't :)