Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10103 closed bug (fixed)

Dialog: Focus management should honor isDefaultPrevented

Reported by: benshu Owned by:
Priority: minor Milestone: 1.11.0
Component: ui.dialog Version: 1.10.4
Keywords: Cc:
Blocked by: Blocking:

Description

Scenario

  • The last tabbable element within a dialog has the focus.
  • The user presses the tab key.

Behavior:

  1. The dialog registers the keydown event of the tab key.
  2. The dialog moves the focus to the first tabbable element of the dialog.

Currently there is no way to prevent the described bahavior. If an independent listener tries to move the focus somewhere else, it is "overriden" by jQuery UI dialog. Because the dialog widget moves the focus with a delay of 1ms there is no reasonable workaround.

I contend that isDefaultPrevented() should be checked and that the focus should only be moved if it returns false.

FYI, the fix for #9646 is broken. Shift-tabbing from the first to the last element no longer works. The focus will remain on the first element.

Change History (6)

comment:1 Changed 4 years ago by Scott González

Status: newopen

I agree with this proposal. The shift-tab behavior is a simple fix as well, looks like it was a copy/paste error.

comment:2 Changed 4 years ago by Scott González

Summary: modal dialog focus magic does not respect isDefaultPreventedDialog: Focus management should honor isDefaultPrevented

comment:3 Changed 4 years ago by Jörn Zaefferer

comment:4 Changed 4 years ago by Jörn Zaefferer

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

Changeset: a0b84767a76098cdcc6375dfe28a7fee866bd395

comment:5 Changed 4 years ago by Scott González

Milestone: none1.11.0
Resolution: fixed
Status: openclosed

comment:6 Changed 4 years ago by Jörn Zaefferer

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

Changeset: 226cc3e9e57c7591ff6a2ee02ffed52ac97786a9

Note: See TracTickets for help on using tickets.