[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][base-browser-115.3.1esr-13.0-1] fixup! Bug 41454: Move focus after calling openPreferences for a sub-category.



Title: GitLab

richard pushed to branch base-browser-115.3.1esr-13.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • 3d78c742
    by Henry Wilkes at 2023-10-11T18:30:21+00:00
    fixup! Bug 41454: Move focus after calling openPreferences for a sub-category.
    
    Bug 42167: Make the auto-focus more reliable.
    
    No longer use the setTimeout to wait a loop, but instead wait for the
    "load" event.
    

1 changed file:

Changes:

  • browser/components/preferences/preferences.js
    ... ... @@ -482,14 +482,23 @@ async function scrollAndHighlight(subcategory, category) {
    482 482
     
    
    483 483
       // We assign a tabindex=-1 to the element so that we can focus it. This allows
    
    484 484
       // us to move screen reader's focus to an arbitrary position on the page.
    
    485
    -  // See tor-browser#41454 and bug 1799153.
    
    486
    -  element.setAttribute("tabindex", "-1");
    
    487
    -  // The element is not always immediately focusable, so we wait until the next
    
    488
    -  // loop.
    
    489
    -  setTimeout(() => {
    
    485
    +  // See tor-browser#41454 and mozilla bug 1799153.
    
    486
    +  const doFocus = () => {
    
    487
    +    element.setAttribute("tabindex", "-1");
    
    490 488
         Services.focus.setFocus(element, Services.focus.FLAG_NOSCROLL);
    
    489
    +    // Immediately remove again now that it has focus.
    
    491 490
         element.removeAttribute("tabindex");
    
    492
    -  });
    
    491
    +  };
    
    492
    +  // The element is not always immediately focusable, so we wait until document
    
    493
    +  // load.
    
    494
    +  if (document.readyState === "complete") {
    
    495
    +    doFocus();
    
    496
    +  } else {
    
    497
    +    // Wait until document load to move focus.
    
    498
    +    // NOTE: This should be called after DOMContentLoaded, where the searchInput
    
    499
    +    // is focused.
    
    500
    +    window.addEventListener("load", doFocus, { once: true });
    
    501
    +  }
    
    493 502
     
    
    494 503
       scrollContentTo(header);
    
    495 504
       element.classList.add("spotlight");
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits