Fixed #33725 -- Made hidden quick filter in admin's navigation sidebar not focusable.
Regression ind915dd1c58
. Follow up to780473d756
.
This commit is contained in:
parent
78bf1565c3
commit
90dcf27114
|
@ -13,6 +13,12 @@
|
|||
navLink.tabIndex = 0;
|
||||
}
|
||||
}
|
||||
function disableNavFilterTabbing() {
|
||||
document.getElementById('nav-filter').tabIndex = -1;
|
||||
}
|
||||
function enableNavFilterTabbing() {
|
||||
document.getElementById('nav-filter').tabIndex = 0;
|
||||
}
|
||||
|
||||
const main = document.getElementById('main');
|
||||
let navSidebarIsOpen = localStorage.getItem('django.admin.navSidebarIsOpen');
|
||||
|
@ -21,6 +27,7 @@
|
|||
}
|
||||
if (navSidebarIsOpen === 'false') {
|
||||
disableNavLinkTabbing();
|
||||
disableNavFilterTabbing();
|
||||
}
|
||||
main.classList.toggle('shifted', navSidebarIsOpen === 'true');
|
||||
|
||||
|
@ -28,9 +35,11 @@
|
|||
if (navSidebarIsOpen === 'true') {
|
||||
navSidebarIsOpen = 'false';
|
||||
disableNavLinkTabbing();
|
||||
disableNavFilterTabbing();
|
||||
} else {
|
||||
navSidebarIsOpen = 'true';
|
||||
enableNavLinkTabbing();
|
||||
enableNavFilterTabbing();
|
||||
}
|
||||
localStorage.setItem('django.admin.navSidebarIsOpen', navSidebarIsOpen);
|
||||
main.classList.toggle('shifted');
|
||||
|
|
|
@ -14,3 +14,6 @@ Bugfixes
|
|||
|
||||
* Fixed a bug in Django 4.0 that caused a crash of ``QuerySet.filter()`` on
|
||||
``IsNull()`` expressions (:ticket:`33705`).
|
||||
|
||||
* Fixed a bug in Django 4.0 where a hidden quick filter toolbar in the admin's
|
||||
navigation sidebar was focusable (:ticket:`33725`).
|
||||
|
|
|
@ -170,6 +170,7 @@ filesystem
|
|||
filesystems
|
||||
flatpage
|
||||
flatpages
|
||||
focusable
|
||||
fooapp
|
||||
formatter
|
||||
formatters
|
||||
|
|
|
@ -148,10 +148,14 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
self.assertEqual(toggle_button.get_attribute("aria-label"), "Toggle navigation")
|
||||
for link in self.selenium.find_elements(By.CSS_SELECTOR, "#nav-sidebar a"):
|
||||
self.assertEqual(link.get_attribute("tabIndex"), "0")
|
||||
filter_input = self.selenium.find_element_by_css_selector("#nav-filter")
|
||||
self.assertEqual(filter_input.get_attribute("tabIndex"), "0")
|
||||
toggle_button.click()
|
||||
# Hidden sidebar is not reachable via keyboard navigation.
|
||||
for link in self.selenium.find_elements(By.CSS_SELECTOR, "#nav-sidebar a"):
|
||||
self.assertEqual(link.get_attribute("tabIndex"), "-1")
|
||||
filter_input = self.selenium.find_element_by_css_selector("#nav-filter")
|
||||
self.assertEqual(filter_input.get_attribute("tabIndex"), "-1")
|
||||
main_element = self.selenium.find_element(By.CSS_SELECTOR, "#main")
|
||||
self.assertNotIn("shifted", main_element.get_attribute("class").split())
|
||||
|
||||
|
@ -188,9 +192,13 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
# Hidden sidebar is not reachable via keyboard navigation.
|
||||
for link in self.selenium.find_elements(By.CSS_SELECTOR, "#nav-sidebar a"):
|
||||
self.assertEqual(link.get_attribute("tabIndex"), "-1")
|
||||
filter_input = self.selenium.find_element_by_css_selector("#nav-filter")
|
||||
self.assertEqual(filter_input.get_attribute("tabIndex"), "-1")
|
||||
toggle_button.click()
|
||||
for link in self.selenium.find_elements(By.CSS_SELECTOR, "#nav-sidebar a"):
|
||||
self.assertEqual(link.get_attribute("tabIndex"), "0")
|
||||
filter_input = self.selenium.find_element_by_css_selector("#nav-filter")
|
||||
self.assertEqual(filter_input.get_attribute("tabIndex"), "0")
|
||||
self.assertEqual(
|
||||
self.selenium.execute_script(
|
||||
"return localStorage.getItem('django.admin.navSidebarIsOpen')"
|
||||
|
|
Loading…
Reference in New Issue