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

Unified Diff: ui/webui/resources/js/cr/ui/page_manager/page_manager.js

Issue 1162293008: Fix some lingering WebUI focus issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: not more or less hacky, just hacky in a different way... Created 5 years, 6 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: ui/webui/resources/js/cr/ui/page_manager/page_manager.js
diff --git a/ui/webui/resources/js/cr/ui/page_manager/page_manager.js b/ui/webui/resources/js/cr/ui/page_manager/page_manager.js
index 578adbd626f99e9abe020f0a1ac64c47203df3cb..8fafc82c4f3de4ab0817a7ff9acd13ac440dd2b2 100644
--- a/ui/webui/resources/js/cr/ui/page_manager/page_manager.js
+++ b/ui/webui/resources/js/cr/ui/page_manager/page_manager.js
@@ -476,9 +476,11 @@ cr.define('cr.ui.pageManager', function() {
if (!overlay || !overlay.canShowPage())
return false;
+ var focusOutlineManager = cr.ui.FocusOutlineManager.forDocument(document);
+
// Save the currently focused element in the page for restoration later.
var currentPage = this.getTopmostVisiblePage();
- if (currentPage)
+ if (currentPage && focusOutlineManager.visible)
currentPage.lastFocusedElement = document.activeElement;
if ((!rootPage || !rootPage.sticky) &&
@@ -495,14 +497,11 @@ cr.define('cr.ui.pageManager', function() {
overlay.didChangeHash();
}
- // Change focus to the overlay if any other control was focused by
- // keyboard before. Otherwise, no one should have focus.
- if (document.activeElement != document.body) {
- if (cr.ui.FocusOutlineManager.forDocument(document).visible)
- overlay.focus();
- if (!overlay.pageDiv.contains(document.activeElement))
- document.activeElement.blur();
- }
+ if (focusOutlineManager.visible)
+ overlay.focus();
+
+ if (!overlay.pageDiv.contains(document.activeElement))
+ document.activeElement.blur();
if ($('search-field') && $('search-field').value == '') {
var section = overlay.associatedSection;
@@ -627,8 +626,14 @@ cr.define('cr.ui.pageManager', function() {
*/
restoreLastFocusedElement_: function() {
var currentPage = this.getTopmostVisiblePage();
- if (currentPage.lastFocusedElement)
+
+ if (!currentPage.lastFocusedElement)
+ return;
+
+ if (cr.ui.FocusOutlineManager.forDocument(document).visible)
currentPage.lastFocusedElement.focus();
+
+ currentPage.lastFocusedElement = null;
},
/**
« chrome/browser/resources/extensions/extensions.js ('K') | « ui/webui/resources/js/cr/ui/overlay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698