Dialog: Track the instance as soon as the dialog is opened

Fixes #10152