From bed33a9b61006b30f169bfeff54f1e411893b315 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Mon, 14 Nov 2016 18:48:02 -0800 Subject: [PATCH] Disallow clicks on disabled buttons. --- accessible/block-options-modal.component.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/accessible/block-options-modal.component.js b/accessible/block-options-modal.component.js index ad765f983..9ae2baabc 100644 --- a/accessible/block-options-modal.component.js +++ b/accessible/block-options-modal.component.js @@ -113,7 +113,15 @@ blocklyApp.BlockOptionsModalComponent = ng.core.Component({ }, // Enter key: selects an action, performs it, and closes the // modal. - '13': function() { + '13': function(evt) { + var button = document.getElementById( + that.getOptionId(that.activeActionButtonIndex)); + if (button.disabled) { + evt.preventDefault(); + evt.stopPropagation(); + return; + } + if (that.activeActionButtonIndex < that.actionButtonsInfo.length) { that.actionButtonsInfo[that.activeActionButtonIndex].action(); @@ -155,11 +163,13 @@ blocklyApp.BlockOptionsModalComponent = ng.core.Component({ } ], // Focuses on the button represented by the given index, if the button - // is not disabled. + // is not disabled. Otherwise, removes any existing focus. focusOnOptionIfPossible: function(index) { var button = document.getElementById(this.getOptionId(index)); if (!button.disabled) { button.focus(); + } else { + document.activeElement.blur(); } }, // Returns the ID for the corresponding option button.