Commit 847eefba authored by Henry Wilkes's avatar Henry Wilkes Committed by morgan
Browse files

BB 41454: Move focus after calling openPreferences for a sub-category.

Temporary fix until mozilla bug 1799153 gets a patch upstream.
parent 53d5a006
Loading
Loading
Loading
Loading
+4 −0
Changes for browser/components/preferences/findInPage.js: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -75,7 +75,11 @@ var gSearchResultsPane = {
      this.searchInput.addEventListener("input", this);
      window.addEventListener("DOMContentLoaded", () => {
        this.searchInput.updateComplete.then(() => {
          // To avoid a race with `scrollAndHighlight`, we only move the focus
          // if it remains at the top of the document. tor-browser#43640.
          if (document.activeElement === document.body) {
            this.searchInput.focus();
          }
        });
        // Initialize other panes in an idle callback.
        window.requestIdleCallback(() => this.initializeCategories());
+24 −0
Changes for browser/components/preferences/preferences.js: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -939,6 +939,30 @@ function scrollAndHighlight(subcategory) {
    return;
  }

  // We focus the first element that we can focus.
  // See tor-browser#41454, tor-browser#45195 and mozilla bug 1799153.
  let focusTarget = elements[0];
  if (focusTarget.tagName === "setting-group") {
    focusTarget = focusTarget.fieldsetEl;
    // Make the heading focusable.
    focusTarget.focusableHeading = true;
    focusTarget.updateComplete.then(() => {
      focusTarget.focusHeading();
    });
  } else {
    // Try focus directly using the focus method, which can be overridden.
    focusTarget.focus();
    if (!focusTarget.contains(document.activeElement)) {
      // Else, try focus the first focusable target.
      Services.focus.moveFocus(
        window,
        focusTarget,
        Services.focus.MOVEFOCUS_FIRST,
        Services.focus.FLAG_NOSCROLL
      );
    }
  }

  elements[0].scrollIntoView({
    behavior: "smooth",
    block: "center",