Skip to content
Snippets Groups Projects
Commit c1c84118 authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

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

Temporary fix until mozilla bug 1799153 gets a patch upstream.
parent f4faa11e
No related branches found
No related tags found
1 merge request!1503TB 43415, part 3: Shuffle commits
......@@ -447,6 +447,26 @@ async function scrollAndHighlight(subcategory) {
}
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 mozilla bug 1799153.
const doFocus = () => {
element.setAttribute("tabindex", "-1");
Services.focus.setFocus(element, Services.focus.FLAG_NOSCROLL);
// Immediately remove again now that it has focus.
element.removeAttribute("tabindex");
};
// The element is not always immediately focusable, so we wait until document
// load.
if (document.readyState === "complete") {
doFocus();
} else {
// Wait until document load to move focus.
// NOTE: This should be called after DOMContentLoaded, where the searchInput
// is focused.
window.addEventListener("load", doFocus, { once: true });
}
scrollContentTo(header);
element.classList.add("spotlight");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment