Dialog: Fix shift-tab handling, focus the correct element

Copy-paste error introduced in df6110c0d424ff3306fdd5576011f2dcf4d242d0

Updates the tabbing test to be more specific about which element should
have focus, instead of only checking if focus is within the dialog.

Ref #9646
Ref #10103
Closes gh-1264
Dialog: Honor preventDefault when managing focus

If event.isDefaultPrevented() is true, the focus management is
completely skipped, assuming the user manages focus manually.

Fixes #10103
Closes gh-1265