Skip to content

Commit 32eecd6

Browse files
authored
fix(tabs): fix focus on keyboard navigation for safari (#2485)
* fix(tabs): removes call to RTI updateActiveItem on tab expand * chore(tabs): add changeset * fix(tabs): update activeItem if its not equal the the event tab * fix(tabs): apply focus to tab on click for safari * chore(tabs): update changeset * fix(tabs): return ids to tabs and panels * fix(tabs): remove id from tab and panel * fix(tabs): remove randomId import * fix(tabs): override focus and apply to shadowroot button * fix(tabs): override focus and apply to shadowroot button * chore(tabs): update changeset * chore(tabs): update changeset
1 parent 9266ee5 commit 32eecd6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@patternfly/elements": patch
3+
---
4+
5+
`BaseTab`:
6+
- fixed Safari focus issue on keyboard navigation
7+
- fixed Safari focus issue on mouse click

elements/pf-tabs/BaseTab.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ export abstract class BaseTab extends LitElement {
6363
}
6464
}
6565

66+
focus() {
67+
this.button.focus();
68+
}
69+
6670
#clickHandler() {
6771
if (!this.disabled && this.#internals.ariaDisabled !== 'true' && this.ariaDisabled !== 'true') {
6872
this.active = true;
73+
this.focus(); // safari fix
6974
}
7075
}
7176

elements/pf-tabs/BaseTabs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ export abstract class BaseTabs extends LitElement {
226226
}
227227

228228
if (event.active) {
229+
if (event.tab !== this.#tabindex.activeItem) {
230+
this.#tabindex.updateActiveItem(event.tab);
231+
}
229232
this.activeIndex = this.#allTabs.findIndex(tab => tab === event.tab);
230-
this.#tabindex.updateActiveItem(this.#activeTab);
231233
}
232234
};
233235

0 commit comments

Comments
 (0)