Skip to content

Commit

Permalink
fix: (CXSPA-8015) improve tab focus visibility (show all four sides o…
Browse files Browse the repository at this point in the history
  • Loading branch information
uroslates authored Nov 27, 2024
1 parent 8702aa8 commit 44c66f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export interface FeatureTogglesInterface {
/**
* Fixes various instances of the focus ring being cropped in the UI.
* The focus ring on interactive elements should have all its sides visible and not include any extra padding.
* Affects styles of: 'CartItemListComponent, CartItemComponent, ListComponent, FutureStockAccordionComponent, QuoteConfirmDialogComponent, MessagingComponent
* Affects styles of: 'CartItemListComponent, CartItemComponent, ListComponent, FutureStockAccordionComponent, QuoteConfirmDialogComponent, MessagingComponent, TabComponent
*/
a11yCroppedFocusRing?: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { BehaviorSubject, Observable, of, Subscription } from 'rxjs';
import { map, take } from 'rxjs/operators';
import { Tab, TabConfig, TAB_MODE } from './tab.model';
import { wrapIntoBounds } from './tab.utils';
import { TranslationService } from '@spartacus/core';
import { TranslationService, useFeatureStyles } from '@spartacus/core';

@Component({
selector: 'cx-tab',
Expand Down Expand Up @@ -53,6 +53,10 @@ export class TabComponent implements OnInit, AfterViewInit, OnDestroy {
mode$: Observable<TAB_MODE>;
protected subscriptions = new Subscription();

constructor() {
useFeatureStyles('a11yCroppedFocusRing');
}

ngOnInit(): void {
this.openTabs$ = new BehaviorSubject<number[]>(this.config?.openTabs ?? []);
this.mode$ = this.getMode();
Expand Down
10 changes: 10 additions & 0 deletions projects/storefrontstyles/scss/components/content/tab/_tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
&:focus {
z-index: 1;
}
@include forFeature('a11yCroppedFocusRing') {
&:focus-visible {
outline-offset: -3px;
}
}

&.active:after,
&:hover:not([disabled]):after {
Expand Down Expand Up @@ -83,6 +88,11 @@
border-radius: var(--cx-tab-panel-border-radius);
padding: var(--cx-tab-panel-padding);
background: var(--cx-tab-panel-bg);
@include forFeature('a11yCroppedFocusRing') {
&.active:focus-visible {
outline-offset: -3px;
}
}
}

.tab {
Expand Down

0 comments on commit 44c66f4

Please sign in to comment.