Dialog: Fix stacking of modal dialog overlays

Fixes #10138
Closes gh-1286