Fix menu dropdown focus traps (#944)

This commit is contained in:
Sascha Ißbrücker
2025-01-11 12:44:20 +01:00
committed by GitHub
parent c3149409b0
commit d2e8a95e3c
5 changed files with 52 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
/* Dropdown */
.dropdown {
--dropdown-focus-display: block;
display: inline-block;
position: relative;
@@ -20,9 +22,13 @@
}
}
&.active .menu,
.dropdown-toggle:focus + .menu,
.menu:hover {
&:focus-within .menu {
/* Use custom CSS property to allow disabling opening on focus when using JS */
display: var(--dropdown-focus-display);
}
&.active .menu {
/* Always show menu when class is added through JS */
display: block;
}