Skip to content

Commit

Permalink
fix: fix focus ring
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMenga committed Apr 18, 2024
1 parent b8a2889 commit da81b1a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/components/card/common/card-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
inset: 0;
border-radius: var(--sbb-card-border-radius);
cursor: pointer;
outline: none;

// Hide focus outline when focus origin is mouse or touch. This is being used as a workaround in various components.
// Handle focus when on the host (button variant)
Expand All @@ -27,7 +28,7 @@
}

// Handle focus on the action (link variant)
:host(:not([data-focus-origin='mouse'], [data-focus-origin='touch'])) :focus-visible & {
:host(:not([data-focus-origin='mouse'], [data-focus-origin='touch'])) &:focus-visible {
@include sbb.focus-outline;
}
}
5 changes: 1 addition & 4 deletions src/components/header/common/header-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@
padding-inline: var(--sbb-header-action-padding-inline);
cursor: pointer;
user-select: none;

// Use !important here to not interfere with Firefox focus ring definition
// which appears in normalize css of several frameworks.
outline: none !important;
outline: none;

&::before {
position: absolute;
Expand Down
23 changes: 10 additions & 13 deletions src/components/menu/common/menu-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
}
}

:is(.sbb-menu-button, .sbb-menu-link) {
text-decoration: none;
display: block;
width: 100%;
color: var(--sbb-menu-action-color);
padding: var(--sbb-spacing-fixed-1x) var(--sbb-menu-action-outer-horizontal-padding);
cursor: var(--sbb-menu-action-cursor);
outline: none;
}

.sbb-menu-action__content {
@include sbb.text-xs--regular;

Expand Down Expand Up @@ -78,19 +88,6 @@
}
}

:is(.sbb-menu-button, .sbb-menu-link) {
text-decoration: none;
display: block;
width: 100%;
color: var(--sbb-menu-action-color);
padding: var(--sbb-spacing-fixed-1x) var(--sbb-menu-action-outer-horizontal-padding);
cursor: var(--sbb-menu-action-cursor);

// Use !important here to not interfere with Firefox focus ring definition
// which appears in normalize css of several frameworks.
outline: none !important;
}

.sbb-menu-action__icon {
display: flex;
min-width: var(--sbb-size-icon-ui-small);
Expand Down
3 changes: 2 additions & 1 deletion src/components/navigation/common/navigation-action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sbb-icon {
hyphens: auto;
text-align: left;
color: var(--sbb-navigation-action-color);
outline: none;

@include sbb.if-forced-colors {
transition: none;
Expand All @@ -85,7 +86,7 @@ sbb-icon {
}

// Handle focus on the action (link variant)
:host(:not([data-focus-origin='mouse'], [data-focus-origin='touch'])) :focus-visible & {
:host(:not([data-focus-origin='mouse'], [data-focus-origin='touch'])) &:focus-visible {
@include navigation-action-focus-outline;
}
}

0 comments on commit da81b1a

Please sign in to comment.