Skip to main content

Search and Top Navigation

#10103 closed bug (fixed)

Opened June 09, 2014 07:21PM UTC

Closed June 10, 2014 12:02PM UTC

Last modified June 10, 2014 12:09PM UTC

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.

Attachments (0)
Change History (6)

Changed June 09, 2014 07:30PM UTC by scottgonzalez comment:1

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.

Changed June 09, 2014 07:32PM UTC by scottgonzalez comment:2

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

Changed June 10, 2014 10:42AM UTC by jzaefferer comment:3

PR for the shift-tab issue: https://github.com/jquery/jquery-ui/pull/1264

Changed June 10, 2014 11:58AM UTC by Jörn Zaefferer comment:4

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

Changed June 10, 2014 12:02PM UTC by scottgonzalez comment:5

milestone: none1.11.0
resolution: → fixed
status: openclosed

Changed June 10, 2014 12:09PM UTC by Jörn Zaefferer comment:6

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