Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus: Remove default z-index #2501

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"path": "./dist/css/boosted.min.css",
"maxSize": "41.5 kB"
"maxSize": "41.75 kB"
},
{
"path": "./dist/js/boosted.bundle.js",
Expand Down
1 change: 1 addition & 0 deletions scss/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
&:focus {
// Boosted mod
&[data-focus-visible-added] {
z-index: $focus-visible-zindex;
outline-offset: add($focus-visible-outer-offset, var(--#{$prefix}accordion-border-width));
box-shadow: 0 0 0 add(var(--#{$prefix}accordion-border-width), $focus-visible-inner-width) var(--#{$prefix}focus-visible-inner-color);
}
Expand Down
6 changes: 6 additions & 0 deletions scss/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
border-color: var(--#{$prefix}btn-hover-border-color);
}

// Boosted mod
&:focus[data-focus-visible-added] {
z-index: $focus-visible-zindex;
}
// End mod

// Boosted mod: no .btn-check + &:hover

// Boosted mod: no &:focus-visible to avoid issue in button tags
Expand Down
5 changes: 0 additions & 5 deletions scss/_list-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@
&[data-focus-visible-added] {
outline-offset: subtract(-$focus-visible-outer-width, var(--#{$prefix}list-group-border-width));
box-shadow: inset 0 0 0 add($focus-visible-inner-width, $focus-visible-outer-width) var(--#{$prefix}focus-visible-inner-color);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done separately if needed, if I remember well it was only an oversight from #1467.

&.active {
outline-color: var(--#{$prefix}focus-visible-inner-color);
box-shadow: inset 0 0 0 add($focus-visible-inner-width, $focus-visible-outer-width) var(--#{$prefix}focus-visible-outer-color);
}
}
}
// End mod
Expand Down
8 changes: 7 additions & 1 deletion scss/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@
border: 0;
@include transition($nav-link-transition);

// Boosted mod: no focus
// Boosted mod: handle focus differently focus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"focus" word at the end to remove

&:hover {
color: var(--#{$prefix}nav-link-hover-color);
text-decoration: if($link-hover-decoration == underline, none, null);
}

// Boosted mod
&:focus[data-focus-visible-added] {
z-index: $focus-visible-zindex;
}
// End mod

// Boosted mod: no `&:focus-visible`

// Disabled state lightens text
Expand Down
6 changes: 5 additions & 1 deletion scss/_pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
border-color: var(--#{$prefix}pagination-hover-border-color);
}

// Boosted mod: no focus
// Boosted mod
&:focus[data-focus-visible-added] {
z-index: $focus-visible-zindex;
}
// End mod

// Boosted mod
&:active,
Expand Down
2 changes: 1 addition & 1 deletion scss/boosted.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
@import "containers";
@import "grid";
@import "tables";
@import "forms";
@import "buttons";
@import "transitions";
@import "dropdown";
@import "button-group";
@import "forms"; // Boosted mod: import after button-group for focus issue
@import "nav";
@import "navbar";
@import "card";
Expand Down
2 changes: 2 additions & 0 deletions scss/forms/_form-check.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
}

&:focus {
z-index: $focus-visible-zindex;
border-color: $form-check-input-focus-border;
// Boosted mod: default outline
box-shadow: $form-check-input-focus-box-shadow;
Expand Down Expand Up @@ -260,6 +261,7 @@
&[data-focus-visible-added]:focus {
+ .btn,
+ .tag {
z-index: $focus-visible-zindex;
@include focus-visible();
}
}
Expand Down
3 changes: 2 additions & 1 deletion scss/forms/_star-rating.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--#{$prefix}star-rating-checked-icon: #{$form-star-rating-checked-icon};
--#{$prefix}star-rating-unchecked-icon: #{$form-star-rating-unchecked-icon};

display: flex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Member Author

@louismaximepiton louismaximepiton Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the display: flex and the removal of float: left changes were needed otherwise, the focus wasn't handled correctly. Here is the rendering without the changes:
image

Edit: Rethinking about this, it could even be display: inline-flex

font-size: $form-star-size;
background-color: transparent;

Expand All @@ -24,7 +25,6 @@

> label,
span {
float: left;
louismaximepiton marked this conversation as resolved.
Show resolved Hide resolved
width: 1em;
height: 1em;

Expand Down Expand Up @@ -54,6 +54,7 @@
}

> [data-focus-visible-added]:focus + label {
z-index: $focus-visible-zindex;
@include focus-visible();
outline-offset: -1px;
box-shadow: inset 0 0 0 add(1px, $focus-visible-inner-width) var(--#{$prefix}focus-visible-inner-color);
Expand Down
3 changes: 1 addition & 2 deletions scss/mixins/_focus.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// scss-docs-start focus-visible
@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)) {
z-index: $zindex;
@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)) {
isolation: isolate;
outline: $width solid $color;
outline-offset: $offset;
Expand Down
6 changes: 6 additions & 0 deletions site/content/docs/5.3/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ toc: true

## v5.3.4

<hr class="mb-4">

### Core

- **Colors**
- <span class="badge text-bg-warning">Warning</span> The dark mode red color hexadecimal value has been updated from `#f66` to `#ff4d4f` after a change in the design specifications to enhance the contrast for a better accessibility. This modification should be transparent for you except if you were using an hardcoded hexadecimal value directly in your websites.

### CSS and Sass variables

- <span class="badge text-bg-danger">Breaking</span> A parameter from the `focus-visible()` mixin has been removed. You don't need the `z-index` parameter anymore. Please reflect these modifications inside your website.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain this has an impact only if the project uses the mixin focus-visible() explicitly.

Proposition:
Breaking A parameter from the focus-visible() mixin has been removed. If you use the focus-visible() mixin in you scss files with a z-index as first parameter, please adapt your code.

Copy link
Member Author

@louismaximepiton louismaximepiton Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried something based on your proposition in c37ccf4.


## v5.3.3

<hr class="mb-4">
Expand Down
Loading