Chromium Code Reviews| 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) { |
|
Dan Beam
2015/06/04 03:30:29
i think this isn't relevant/desired any more
dmazzoni
2015/06/04 03:34:56
I think it is - a lot of the overlays are dialogs,
Dan Beam
2015/06/04 18:50:35
The code on the right does this *more*.
Previous
|
| - 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(); |
|
Dan Beam
2015/06/04 03:30:29
i honestly don't know what was happening by keepin
dmazzoni
2015/06/04 03:34:56
Wait, isn't this the code that restores focus afte
Dan Beam
2015/06/04 18:50:35
We still restore focus. We just now actually clear
|
| + |
| + currentPage.lastFocusedElement = null; |
| }, |
| /** |