Skip to content

Commit e4957fa

Browse files
committed
fix(tab): A11Y - manage tabindex and set focus when active.
1 parent d9f8c13 commit e4957fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/src/components/tab/tab.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export class Tab implements ComponentInterface {
5656
@Watch('active')
5757
changeActive(isActive: boolean) {
5858
if (isActive) {
59+
// ensure tabindex gets updated before setting focus to the element
60+
setTimeout(() => {
61+
this.el.focus();
62+
}, 50);
63+
5964
this.prepareLazyLoaded();
6065
}
6166
}
@@ -83,6 +88,7 @@ export class Tab implements ComponentInterface {
8388
'ion-page': component === undefined,
8489
'tab-hidden': !active,
8590
}}
91+
tabIndex={!active ? -1 : 0}
8692
>
8793
<slot></slot>
8894
</Host>

0 commit comments

Comments
 (0)