Chromium Code Reviews| Index: chrome/browser/resources/print_preview/search/destination_list.js |
| diff --git a/chrome/browser/resources/print_preview/search/destination_list.js b/chrome/browser/resources/print_preview/search/destination_list.js |
| index 9b9647a00bf39eb3414b75b50c2300473f3cf6c5..60f6e32a0ccd1102588008112a4bea093f8a2240 100644 |
| --- a/chrome/browser/resources/print_preview/search/destination_list.js |
| +++ b/chrome/browser/resources/print_preview/search/destination_list.js |
| @@ -306,7 +306,10 @@ cr.define('print_preview', function() { |
| }); |
| // Update the existing items, add the new ones (preserve the focused one). |
| var listEl = this.getChildElement('.destination-list > ul'); |
| - var focusedEl = listEl.querySelector(':focus'); |
| + // We need to use activeElement instead of :focus selector, which doesn't |
| + // work in an inactive page. See crbug.com/723579. |
|
dpapad
2017/05/23 18:57:30
Out of curiosity, does crbug.com/723579 happen for
tkent
2017/05/24 01:37:17
:focus-within means just "contains a :focus elemen
|
| + var focusedEl = listEl.contains(document.activeElement) ? |
| + document.activeElement : null; |
| for (var i = 0; i < numItems; i++) { |
| var destination = assert(destinations[i]); |
| var listItem = visibleListItems[destination.id]; |
| @@ -332,11 +335,13 @@ cr.define('print_preview', function() { |
| var itemEl = listItem.getElement(); |
| // Preserve focused inner element, if there's one. |
| - var focusedInnerEl = focusedEl ? itemEl.querySelector(':focus') : null; |
| + var focusedInnerEl = focusedEl && itemEl.contains(focusedEl) ? |
| + focusedEl : null; |
| if (focusedEl) |
| itemEl.classList.add('moving'); |
| // Move it to the end of the list. |
| - listEl.appendChild(itemEl); |
| + if (listEl.lastChild != itemEl) |
|
dpapad
2017/05/23 18:57:30
Did you mean to remove this in patch#2?
tkent
2017/05/24 01:37:17
Oops. Removed.
|
| + listEl.appendChild(itemEl); |
| // Restore focus. |
| if (focusedEl) { |
| if (focusedEl == itemEl || focusedEl == focusedInnerEl) |