Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't attempt to focus a disabled button. This causes the modal dialog

to lose focus -- and the button isn't focused either.

Tested:
Manually on Chrome + unit test

R=nicksantos
DELTA=14 (13 added, 0 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6091


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2422 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
commit 061c95441b5be83379aa5114d519573ab8d37332 1 parent 22f7e9e
mariakhomenko@google.com authored
Showing with 14 additions and 1 deletion.
  1. +1 −1  closure/goog/ui/dialog.js
  2. +13 −0 closure/goog/ui/dialog_test.html
View
2  closure/goog/ui/dialog.js
@@ -760,7 +760,7 @@ goog.ui.Dialog.prototype.focus = function() {
var doc = this.getDomHelper().getDocument();
var buttons = this.buttonEl_.getElementsByTagName('button');
for (var i = 0, button; button = buttons[i]; i++) {
- if (button.name == defaultButton) {
+ if (button.name == defaultButton && !button.disabled) {
try {
// Reopening a dialog can cause focusing the button to fail in
// WebKit and Opera. Shift the focus to a temporary <input>
View
13 closure/goog/ui/dialog_test.html
@@ -80,6 +80,19 @@
assertEquals(2, focusCounter);
}
+ function testNoDisabledButtonFocus() {
+ dialog.setVisible(false);
+ var buttonEl =
+ dialog.getButtonSet().getButton(goog.ui.Dialog.DefaultButtonKeys.OK);
+ buttonEl.disabled = true;
+ var focused = false;
+ buttonEl.focus = function() {
+ focused = true;
+ }
+ dialog.setVisible(true);
+ assertFalse('Should not have called focus on disabled button', focused);
+ }
+
function testNoTitleClose() {
assertTrue(goog.style.isElementShown(dialog.getTitleCloseElement()));
dialog.setHasTitleCloseButton(false);
Please sign in to comment.
Something went wrong with that request. Please try again.