Stop parents of attached modal dialogs from disappearing while the dialog is open

Fixes #2099
Fixes #2675