Skip to content

Commit 1d011ed

Browse files
Focus: Remove default z-index (#2501)
--------- Co-authored-by: Hannah Issermann <[email protected]>
1 parent 4d6482b commit 1d011ed

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

scss/_accordion.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
&:focus {
8282
// Boosted mod
8383
&[data-focus-visible-added] {
84+
z-index: $focus-visible-zindex; // Make sure the focused accordion button is displayed over its next sibling
8485
outline-offset: add($focus-visible-outer-offset, var(--#{$prefix}accordion-border-width));
8586
box-shadow: 0 0 0 add(var(--#{$prefix}accordion-border-width), $focus-visible-inner-width) var(--#{$prefix}focus-visible-inner-color);
8687
}

scss/_buttons.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
border-color: var(--#{$prefix}btn-hover-border-color);
5353
}
5454

55+
// Boosted mod: make sure the focused button is displayed over its next sibling
56+
&:focus[data-focus-visible-added] {
57+
z-index: $focus-visible-zindex;
58+
}
59+
// End mod
60+
5561
// Boosted mod: no .btn-check + &:hover
5662

5763
// Boosted mod: no &:focus-visible to avoid issue in button tags

scss/_list-group.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@
117117
&[data-focus-visible-added] {
118118
outline-offset: subtract(-$focus-visible-outer-width, var(--#{$prefix}list-group-border-width));
119119
box-shadow: inset 0 0 0 add($focus-visible-inner-width, $focus-visible-outer-width) var(--#{$prefix}focus-visible-inner-color);
120-
121-
&.active {
122-
outline-color: var(--#{$prefix}focus-visible-inner-color);
123-
box-shadow: inset 0 0 0 add($focus-visible-inner-width, $focus-visible-outer-width) var(--#{$prefix}focus-visible-outer-color);
124-
}
125120
}
126121
}
127122
// End mod

scss/_nav.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@
3434
border: 0;
3535
@include transition($nav-link-transition);
3636

37-
// Boosted mod: no focus
37+
// Boosted mod: handle focus differently
3838
&:hover {
3939
color: var(--#{$prefix}nav-link-hover-color);
4040
text-decoration: if($link-hover-decoration == underline, none, null);
4141
}
4242

43+
// Boosted mod: make sure the focused nav link is displayed over its next sibling
44+
&:focus[data-focus-visible-added] {
45+
z-index: $focus-visible-zindex;
46+
}
47+
// End mod
48+
4349
// Boosted mod: no `&:focus-visible`
4450

4551
// Disabled state lightens text

scss/_pagination.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
border-color: var(--#{$prefix}pagination-hover-border-color);
7373
}
7474

75-
// Boosted mod: no focus
75+
// Boosted mod: make sure the focused page link is displayed over its next sibling
76+
&:focus[data-focus-visible-added] {
77+
z-index: $focus-visible-zindex;
78+
}
79+
// End mod
7680

7781
// Boosted mod
7882
&:active,

scss/forms/_form-check.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
}
6161

6262
&:focus {
63+
z-index: $focus-visible-zindex; // Boosted mod: make sure the focused input is displayed over its next sibling
6364
border-color: $form-check-input-focus-border;
6465
// Boosted mod: default outline
6566
box-shadow: $form-check-input-focus-box-shadow;
@@ -266,6 +267,7 @@
266267
&[data-focus-visible-added]:focus {
267268
+ .btn,
268269
+ .tag {
270+
z-index: $focus-visible-zindex; // Make sure the focused button check is displayed over its next sibling
269271
@include focus-visible();
270272
}
271273
}

scss/forms/_star-rating.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
--#{$prefix}star-rating-checked-icon: #{$form-star-rating-checked-icon};
1010
--#{$prefix}star-rating-unchecked-icon: #{$form-star-rating-unchecked-icon};
1111

12+
display: inline-flex;
1213
font-size: $form-star-size;
1314
background-color: transparent;
1415

@@ -24,7 +25,6 @@
2425

2526
> label,
2627
span {
27-
float: left;
2828
width: 1em;
2929
height: 1em;
3030

@@ -42,6 +42,10 @@
4242
}
4343
}
4444

45+
span {
46+
float: left;
47+
}
48+
4549
> input:checked ~ label::before,
4650
.checked ~ span::before {
4751
background-color: var(--#{$prefix}star-rating-unchecked-color);
@@ -54,6 +58,7 @@
5458
}
5559

5660
> [data-focus-visible-added]:focus + label {
61+
z-index: $focus-visible-zindex; // Make sure the focused star is displayed over its next sibling
5762
@include focus-visible();
5863
outline-offset: -1px;
5964
box-shadow: inset 0 0 0 add(1px, $focus-visible-inner-width) var(--#{$prefix}focus-visible-inner-color);

scss/mixins/_focus.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// scss-docs-start focus-visible
2-
@mixin focus-visible($zindex: $focus-visible-zindex, $color: var(--#{$prefix}focus-visible-outer-color), $width: $focus-visible-outer-width, $offset: $focus-visible-outer-offset, $box-width: $focus-visible-inner-width, $box-color: var(--#{$prefix}focus-visible-inner-color)) {
3-
z-index: $zindex;
2+
@mixin focus-visible($color: var(--#{$prefix}focus-visible-outer-color), $width: $focus-visible-outer-width, $offset: $focus-visible-outer-offset, $box-width: $focus-visible-inner-width, $box-color: var(--#{$prefix}focus-visible-inner-color)) {
43
isolation: isolate;
54
outline: $width solid $color;
65
outline-offset: $offset;

site/content/docs/5.3/migration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ toc: true
1111

1212
## v5.3.4
1313

14+
<hr class="mb-4">
15+
1416
### Core
1517

1618
- **Colors**
@@ -61,6 +63,10 @@ toc: true
6163
</ul>
6264
</details>
6365

66+
### CSS and Sass variables
67+
68+
- <span class="badge text-bg-danger">Breaking</span> A parameter from the `focus-visible()` mixin has been removed. If you use the `focus-visible()` mixin in your scss files with a `z-index` as a parameter, please adapt your code.
69+
6470
## v5.3.3
6571

6672
<hr class="mb-4">

0 commit comments

Comments
 (0)