Fix for Dialogs steal keyboard focus and don't give it back

Also check for previousKeyboardFocus and previousScrollFocus before cancelling a focus change