Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3877)

Unified Diff: chrome/browser/resources/extensions/extensions.js

Issue 862403006: extensions: fix focus management for all dialogs (not just options). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@classList-fix
Patch Set: toggle Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/extensions/extensions.js
diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js
index 9c3bc1d9322e76ad1a05106d87fe7c22a3398f45..81d27dc6a9f3474e4468d6391e82b5e5e8a65deb 100644
--- a/chrome/browser/resources/extensions/extensions.js
+++ b/chrome/browser/resources/extensions/extensions.js
@@ -379,13 +379,8 @@ cr.define('extensions', function() {
*/
ExtensionSettings.showOverlay = function(node) {
var pageDiv = $('extension-settings');
- if (node) {
- pageDiv.style.width = window.getComputedStyle(pageDiv).width;
- document.body.classList.add('no-scroll');
- } else {
- document.body.classList.remove('no-scroll');
- pageDiv.style.width = '';
- }
+ pageDiv.style.width = node ? window.getComputedStyle(pageDiv).width : '';
+ document.body.classList.toggle('no-scroll', node);
var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay();
if (currentlyShowingOverlay) {
@@ -394,8 +389,11 @@ cr.define('extensions', function() {
}
if (node) {
- if (document.activeElement != document.body)
- document.activeElement.blur();
+ var lastFocused = document.activeElement;
+ $('overlay').addEventListener('cancelOverlay', function f() {
+ lastFocused.focus();
not at google - send to devlin 2015/02/06 21:31:38 Correct me if I'm wrong (in which case I'm trying
Dan Beam 2015/02/06 21:50:02 i know
+ $('overlay').removeEventListener('cancelOverlay', f);
+ });
node.classList.add('showing');
}
@@ -405,10 +403,29 @@ cr.define('extensions', function() {
}
$('overlay').hidden = !node;
+
+ if (node)
+ ExtensionSettings.focusOverlay();
+
uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' :
'stopInterceptingEvents');
};
+ ExtensionSettings.focusOverlay = function() {
+ var currentlyShowingOverlay = ExtensionSettings.getCurrentOverlay();
+ assert(currentlyShowingOverlay);
+
+ if (cr.ui.FocusOutlineManager.forDocument(document).visible) {
+ var extraToFocus = '#extension-options-overlay-guest extensionoptions';
+ cr.ui.setInitialFocus(currentlyShowingOverlay, extraToFocus);
+ }
+
+ if (!currentlyShowingOverlay.contains(document.activeElement)) {
+ // Make sure focus isn't stuck behind the overlay.
+ document.activeElement.blur();
+ }
+ };
+
/**
* Utility function to find the width of various UI strings and synchronize
* the width of relevant spans. This is crucial for making sure the

Powered by Google App Engine
This is Rietveld 408576698