Skip to content

Commit

Permalink
fix: (CXSPA-9029) Tab. UI activates on receiving focus.
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavSukhanov committed Jan 13, 2025
1 parent bf10fab commit 2b51dba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ export interface FeatureTogglesInterface {
*/
a11yPopoverHighContrast?: boolean;

/**
* 'TabComponent' disallow automatic tab activation.
*/
a11yTabsManualActivation?: boolean;

/**
* Adds Datepicker and Combobox label and corrects heading order for 'CheckoutScheduleReplenishmentOrderComponent'.
*/
Expand Down Expand Up @@ -990,6 +995,7 @@ export const defaultFeatureToggles: Required<FeatureTogglesInterface> = {
a11yReorderDialog: true,
a11yPopoverFocus: true,
a11yPopoverHighContrast: false,
a11yTabsManualActivation: false,
a11yScheduleReplenishment: true,
a11yScrollToTop: true,
a11ySavedCartsZoom: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ if (environment.cpq) {
a11yReorderDialog: true,
a11yPopoverFocus: true,
a11yPopoverHighContrast: true,
a11yTabsManualActivation: false,
a11yScheduleReplenishment: true,
a11yScrollToTop: true,
a11ySavedCartsZoom: true,
Expand Down
27 changes: 21 additions & 6 deletions projects/storefrontlib/cms-components/content/tab/tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ 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, useFeatureStyles } from '@spartacus/core';
import {
TranslationService,
useFeatureStyles,
FeatureConfigService,
} from '@spartacus/core';

@Component({
selector: 'cx-tab',
Expand All @@ -46,6 +50,9 @@ export class TabComponent implements OnInit, AfterViewInit, OnDestroy {
protected breakpointService = inject(BreakpointService);
protected translationService = inject(TranslationService);
protected cd = inject(ChangeDetectorRef);
private featureConfigService = inject(FeatureConfigService, {
optional: true,
});

@ViewChildren('tabHeader') tabHeaders: QueryList<any>;

Expand Down Expand Up @@ -111,11 +118,19 @@ export class TabComponent implements OnInit, AfterViewInit, OnDestroy {
selectOrFocus(tabNum: number, mode: TAB_MODE, event: KeyboardEvent): void {
event.preventDefault();

switch (mode) {
case TAB_MODE.TAB:
return this.select(tabNum, mode);
case TAB_MODE.ACCORDIAN:
return this.focus(tabNum);
if (this.featureConfigService?.isEnabled('a11yTabsManualActivation')) {
switch (mode) {
case TAB_MODE.TAB:
case TAB_MODE.ACCORDIAN:
return this.focus(tabNum);
}
} else {
switch (mode) {
case TAB_MODE.TAB:
return this.select(tabNum, mode);
case TAB_MODE.ACCORDIAN:
return this.focus(tabNum);
}
}
}

Expand Down

0 comments on commit 2b51dba

Please sign in to comment.