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

fix(components/tabs): puts focus on active tab in mobile view #3182

Merged
merged 7 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class="sky-vertical-tabset-group-container"
[@tabGroupEnter]="tabService.animationTabsVisibleState"
[ngClass]="{ 'sky-vertical-tabset-hidden': !tabService.tabsVisible() }"
(@tabGroupEnter.done)="tabsetFocus()"
(keydown.arrowdown)="tabGroupsArrowDown(); $event.preventDefault()"
(keydown.arrowup)="tabGroupsArrowUp(); $event.preventDefault()"
(focusin)="trapFocusInTablist()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,33 @@ describe('Vertical tabset component', () => {
flush();
}));

it('should focus the active tab when the tab container is opened on mobile view', fakeAsync(() => {
mediaQueryController.setBreakpoint('xs');
const fixture = createTestComponent();
fixture.detectChanges();

const el = fixture.nativeElement;

// click show tabs button to open tab group
let showTabsButton = el.querySelector('.sky-vertical-tabset-show-tabs-btn');
showTabsButton.click();
fixture.detectChanges();

// click second tab in second group
clickGroupButton(fixture, 1);
clickTab(fixture, 1, 1);

// open tab group and wait for timer to finish
showTabsButton = el.querySelector('.sky-vertical-tabset-show-tabs-btn');
showTabsButton.click();
fixture.detectChanges();

//wait for animation to finish
tick();

expect(elementHasFocus(getTab(fixture, 1, 1))).toBeTrue();
}));

it('should focus the first tab when the tabs container is focused and no tab is active', () => {
mediaQueryController.setBreakpoint('lg');
const fixture = createTestComponent();
Expand Down
Loading