-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix 7598: showModalDialogUsingTemplate doesn't blur current editor #7677
Conversation
You can't even expect a dialog to have one button. Most have, but some not. |
$primaryBtn.focus(); | ||
// If not, set it to any other button | ||
} else { | ||
$dlg.find(".dialog-button:enabled:eq(0)").focus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will select a button in the modal-body
if there's one. I believe only buttons in the fooder should be focussed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Nice catch!
I just got some time to fix this. It will now try to focus the primary button, then any other button in the footer and finally the actual dialog, which should now actually work for every dialog. |
|
||
// Set focus to the primary button, to any other button, or to the dialog depending | ||
// if there are buttons | ||
if ($primaryBtn.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We not try and set focus to the element with the lowest tabindex
first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how that will work. But maybe we can first focus any input.
This seems fine as a default behavior to me. Well-behaved dialogs that want to set focus to a specific element like an input field should be explicitly setting focus anyway. This is just a catch-all for simple dialogs with buttons. Merging. |
Fix 7598: showModalDialogUsingTemplate doesn't blur current editor
Since every dialog has at least one button that is not disabled (to be able to close the dialog), this will set the focus on any other button when the primary one is disabled.