aboutsummaryrefslogtreecommitdiff
path: root/scss
diff options
context:
space:
mode:
authorPatrick H. Lauke <[email protected]>2020-12-11 23:28:45 +0200
committerXhmikosR <[email protected]>2020-12-15 09:22:14 +0200
commiteae52b1cb0af18c5bf3fddd660f53d58d689cd63 (patch)
tree5bda1d015ef474c9ba5180b3c61c3d344fa9a2e7 /scss
parent9b6c81514831038646fb921e8fbacf702a56be04 (diff)
downloadbootstrap-eae52b1cb0af18c5bf3fddd660f53d58d689cd63.tar.xz
bootstrap-eae52b1cb0af18c5bf3fddd660f53d58d689cd63.zip
Expand `visually-hidden-focusable` so it can be used on a container, so the container becomes visible when focus is inside it / on one of its child elements.
Diffstat (limited to 'scss')
-rw-r--r--scss/helpers/_visually-hidden.scss2
-rw-r--r--scss/mixins/_visually-hidden.scss5
2 files changed, 4 insertions, 3 deletions
diff --git a/scss/helpers/_visually-hidden.scss b/scss/helpers/_visually-hidden.scss
index 0a843d383..4760ff03d 100644
--- a/scss/helpers/_visually-hidden.scss
+++ b/scss/helpers/_visually-hidden.scss
@@ -3,6 +3,6 @@
//
.visually-hidden,
-.visually-hidden-focusable:not(:focus) {
+.visually-hidden-focusable:not(:focus):not(:focus-within) {
@include visually-hidden();
}
diff --git a/scss/mixins/_visually-hidden.scss b/scss/mixins/_visually-hidden.scss
index d980696c8..ed7bc9c13 100644
--- a/scss/mixins/_visually-hidden.scss
+++ b/scss/mixins/_visually-hidden.scss
@@ -17,12 +17,13 @@
border: 0 !important;
}
-// Use to only display content when it's focused.
+// Use to only display content when it's focused, or one of its child elements is focused
+// (i.e. when focus is within the element/container that the class was applied to)
//
// Useful for "Skip to main content" links; see https://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1
@mixin visually-hidden-focusable() {
- &:not(:focus) {
+ &:not(:focus):not(:focus-within) {
@include visually-hidden();
}
}