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

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



Title: GitLab

Pier Angelo Vendrame pushed to branch tor-browser-115.3.1esr-13.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • 00e9622f
    by Henry Wilkes at 2023-10-11T11:24:18+01: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
    ... ... @@ -491,14 +491,23 @@ async function scrollAndHighlight(subcategory, category) {
    491 491
     
    
    492 492
       // We assign a tabindex=-1 to the element so that we can focus it. This allows
    
    493 493
       // us to move screen reader's focus to an arbitrary position on the page.
    
    494
    -  // See tor-browser#41454 and bug 1799153.
    
    495
    -  element.setAttribute("tabindex", "-1");
    
    496
    -  // The element is not always immediately focusable, so we wait until the next
    
    497
    -  // loop.
    
    498
    -  setTimeout(() => {
    
    494
    +  // See tor-browser#41454 and mozilla bug 1799153.
    
    495
    +  const doFocus = () => {
    
    496
    +    element.setAttribute("tabindex", "-1");
    
    499 497
         Services.focus.setFocus(element, Services.focus.FLAG_NOSCROLL);
    
    498
    +    // Immediately remove again now that it has focus.
    
    500 499
         element.removeAttribute("tabindex");
    
    501
    -  });
    
    500
    +  };
    
    501
    +  // The element is not always immediately focusable, so we wait until document
    
    502
    +  // load.
    
    503
    +  if (document.readyState === "complete") {
    
    504
    +    doFocus();
    
    505
    +  } else {
    
    506
    +    // Wait until document load to move focus.
    
    507
    +    // NOTE: This should be called after DOMContentLoaded, where the searchInput
    
    508
    +    // is focused.
    
    509
    +    window.addEventListener("load", doFocus, { once: true });
    
    510
    +  }
    
    502 511
     
    
    503 512
       scrollContentTo(header);
    
    504 513
       element.classList.add("spotlight");
    

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