[tbb-commits] [tor-browser] 12/90: Bug 41454: Move focus after calling openPreferences for a sub-category.

gitolite role git at cupani.torproject.org
Tue Nov 22 09:57:47 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-102.5.0esr-12.0-1
in repository tor-browser.

commit d35625b614e77f7c260209959d28992a1d0ae6be
Author: Henry Wilkes <henry at torproject.org>
AuthorDate: Tue Nov 15 11:48:04 2022 +0000

    Bug 41454: Move focus after calling openPreferences for a sub-category.
    
    Temporary fix until mozilla bug 1799153 gets a patch upstream.
---
 browser/components/preferences/preferences.js | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/browser/components/preferences/preferences.js b/browser/components/preferences/preferences.js
index 0b97e8c3cb59..7a6e16591bac 100644
--- a/browser/components/preferences/preferences.js
+++ b/browser/components/preferences/preferences.js
@@ -460,6 +460,17 @@ async function scrollAndHighlight(subcategory, category) {
   }
   let header = getClosestDisplayedHeader(element);
 
+  // We assign a tabindex=-1 to the element so that we can focus it. This allows
+  // us to move screen reader's focus to an arbitrary position on the page.
+  // See tor-browser#41454 and bug 1799153.
+  element.setAttribute("tabindex", "-1");
+  // The element is not always immediately focusable, so we wait until the next
+  // loop.
+  setTimeout(() => {
+    Services.focus.setFocus(element, Services.focus.FLAG_NOSCROLL);
+    element.removeAttribute("tabindex");
+  });
+
   scrollContentTo(header);
   element.classList.add("spotlight");
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list