If dialog2 is opened from dialog1 and you close dialog2 instead of the focus returning to dialog1 the lister gains focus. Similar to how you set the Dialog.window property to a parent lister window. It should be allowed so a dialog can be set as the parent window too. This would also prevent dialog2 from being able to going behind dialog1.
In the provided sample there is two 'detached' dialogs, one opening the other with the lister set as the parent window. As it sits right now it's demonstrating what I described above.
I realize now the reason of the focusing problem was because dialog2 had the lister set as parent window, rather than not being set. If the parent window isn't set for dialog2 it solves the focusing issue but it doesn't center over the lister/dialog1 which is not a huge problem.
Since my first post I've made other discoveries that I will explain here, now.
A problem is when opening a detached dialog, from a detached dialog (See sample). You can return to the initial dialog and click buttons while dialog2 is open. If you click the button that opened dialog2 (from dialog1) while dialog2 is open, then close dialog2 it will open again right after it's closed.
Modal dialog - prevents access to other windows
Modeless dialog - allows access to other windows
As it sits right now, dialogs (at least custom dialogs) within DOpus scripting are all modeless. I think a dialog should be able to be set as a parent window so it appears centered over the window that opened it, and parent window regains focus when second dialog is closed. In addition, the option to make it modeless or a modal dialog. In the case of opening a detached dialog from another a modal type dialog would solve the problem.