Skip to content

Commit a3fa621

Browse files
authored
Merge branch 'main' into docs/remove-skip-link-animation
2 parents 5218609 + f2217cc commit a3fa621

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

.changeset/late-actors-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/elements": patch
3+
---
4+
5+
`pf-accordion`: fixed issue with focus event triggering incorrect tabindex

elements/pf-accordion/BaseAccordion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export abstract class BaseAccordion extends LitElement {
9797
get #activeHeader() {
9898
const { headers } = this;
9999
const index = headers.findIndex(header => header.matches(':focus,:focus-within'));
100-
return headers.at(index);
100+
return index > -1 ? headers.at(index) : undefined;
101101
}
102102

103103
protected expandedSets = new Set<number>();
@@ -162,7 +162,7 @@ export abstract class BaseAccordion extends LitElement {
162162
this.updateAccessibility();
163163
}
164164

165-
#updateActiveHeader() {
165+
#updateActiveHeader(event: FocusEvent) {
166166
if (this.#activeHeader) {
167167
this.#headerIndex.updateActiveItem(this.#activeHeader);
168168
}

elements/pf-accordion/test/pf-accordion.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ describe('<pf-accordion>', function() {
386386
});
387387
});
388388

389-
390389
describe('Shift+Tab', function() {
391390
beforeEach(press('Shift+Tab'));
392391
it('moves focus to the body', function() {
@@ -614,7 +613,7 @@ describe('<pf-accordion>', function() {
614613
describe('Tab', function() {
615614
beforeEach(press('Tab'));
616615
it('moves focus to the body', function() {
617-
expect(document.activeElement).to.equal(header3);
616+
expect(document.activeElement).to.equal(document.body);
618617
});
619618
describe('Shift+Tab', function() {
620619
beforeEach(press('Shift+Tab'));
@@ -1189,7 +1188,7 @@ describe('<pf-accordion>', function() {
11891188

11901189
describe('Navigating from parent to child accordion', function() {
11911190
describe('Opening the panel containing the nested accordion and pressing TAB', function() {
1192-
beforeEach(press(' '));
1191+
beforeEach(press('Space'));
11931192
beforeEach(press('Tab'));
11941193
it('moves focus to the nested accordion header', function() {
11951194
expect(document.activeElement).to.equal(nestedHeaderOne);
@@ -1225,8 +1224,8 @@ describe('<pf-accordion>', function() {
12251224

12261225
describe('Tab', function() {
12271226
beforeEach(press('Tab'));
1228-
it('should move focus back to the parent accordion', function() {
1229-
expect(document.activeElement).to.equal(topLevelHeaderThree);
1227+
it('should move focus back to the body', function() {
1228+
expect(document.activeElement).to.equal(document.body);
12301229
});
12311230
});
12321231
});

0 commit comments

Comments
 (0)