Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix 7598: showModalDialogUsingTemplate doesn't blur current editor #7677

Merged
merged 2 commits into from
Jun 3, 2014

Conversation

TomMalbran
Copy link
Contributor

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.

@marcelgerber
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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!

@TomMalbran
Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@njx
Copy link
Contributor

njx commented Jun 3, 2014

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.

njx added a commit that referenced this pull request Jun 3, 2014
Fix 7598: showModalDialogUsingTemplate doesn't blur current editor
@njx njx merged commit 9bbfcea into master Jun 3, 2014
@njx njx deleted the tom/issue-7598 branch June 3, 2014 23:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants