Search and Top Navigation
#5950 closed enhancement (wontfix)
Opened August 14, 2010 11:22AM UTC
Closed August 14, 2010 12:15PM UTC
Last modified October 23, 2012 01:44PM UTC
Create an option to disable the focusing code in dialog.open
Reported by: | erikkallen | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ui.dialog | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
dialog.open contains the code below (as of 1.7.2, I checked the latest release and the code is similar).
The filters with :tabbable are nice, but if you have complex content in the dialog, they can take a long time to run. Some of my dialogs take minutes(!) to open on older machines with IE6. Monkey-patching dialog.open to remove the tabbing code made the dialog open instantly, so the tabbing is obviously a major performance hog for complex dialogs.
I therefore suggest adding an option to disable this code in a future version, although that might require another way of determining if the focus leaves a modal dialog.
Relevant code from 1.7.2:
prevent tabbing out of modal dialogs
(options.modal && uiDialog.bind('keypress.ui-dialog', function(event) {
if (event.keyCode != $.ui.keyCode.TAB) {
return;
}
var tabbables = $(':tabbable', this),
first = tabbables.filter(':first')[0],
last = tabbables.filter(':last')[0];
if (event.target == last && !event.shiftKey) {
setTimeout(function() {
first.focus();
}, 1);
} else if (event.target == first && event.shiftKey) {
setTimeout(function() {
last.focus();
}, 1);
}
}));
set focus to the first tabbable element in the content area or the first button
// if there are no tabbable elements, set focus on the dialog itself
$([])
.add(uiDialog.find('.ui-dialog-content :tabbable:first'))
.add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
.add(uiDialog)
.filter(':first')
.focus();
Disabling this code would cause accessibility problems. You'll be able to deal with the performance issue when #4731 is implemented and you can explicitly specify which element should gain focus.