Bug 1404651 - keep focus in the tabstrip when the focus has shifted with the arrow keys, r=dao
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 Oct 2017 13:29:53 +0100
changeset 679081 0304a90aee90618165af50193ea6255c54a6b9ea
parent 679080 fea45716484e7b504a027558aed895127472d598
child 679082 013a71e3da4e6d91c444b8af5e088547b718cf06
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersdao
bugs1404651
milestone58.0a1
Bug 1404651 - keep focus in the tabstrip when the focus has shifted with the arrow keys, r=dao MozReview-Commit-ID: Brm9jImW9bc
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1418,23 +1418,24 @@
           oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused);
 
           if (this.isFindBarInitialized(oldTab)) {
             let findBar = this.getFindBar(oldTab);
             oldTab._findBarFocused = (!findBar.hidden &&
               findBar._findField.getAttribute("focused") == "true");
           }
 
-          // If focus is in the tab bar, retain it there.
-          if (document.activeElement == oldTab) {
-            // We need to explicitly focus the new tab, because
-            // tabbox.xml does this only in some cases.
+          let activeEl = document.activeElement;
+          // If focus is on the old tab, move it to the new tab.
+          if (activeEl == oldTab) {
             newTab.focus();
-          } else if (gMultiProcessBrowser && document.activeElement !== newBrowser) {
-
+          } else if (gMultiProcessBrowser && activeEl != newBrowser && activeEl != newTab) {
+            // In e10s, if focus isn't already in the tabstrip or on the new browser,
+            // and the new browser's previous focus wasn't in the url bar but focus is
+            // there now, we need to adjust focus further.
             let keepFocusOnUrlBar = newBrowser &&
                                     newBrowser._urlbarFocused &&
                                     gURLBar &&
                                     gURLBar.focused;
             if (!keepFocusOnUrlBar) {
               // Clear focus so that _adjustFocusAfterTabSwitch can detect if
               // some element has been focused and respect that.
               document.activeElement.blur();