Skip to content

Commit

Permalink
Merge pull request #15831 from primefaces/issue-15830
Browse files Browse the repository at this point in the history
Fixed #15830 - Accessibility: Tree inside an Accordion (arrow navigat…
  • Loading branch information
cetincakiroglu committed Jun 13, 2024
2 parents f8825b1 + 6a60ba8 commit bbb9bb2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,18 +466,12 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
}
}

isInput(event): boolean {
const { tagName } = event.target;
return tagName?.toLowerCase() === 'input';
}

isTextArea(event): boolean {
const { tagName } = event.target;
return tagName?.toLowerCase() === 'textarea';
focusedElementIsAccordionHeader() {
return document.activeElement.tagName.toLowerCase() === 'a' && document.activeElement.classList.contains('p-accordion-header-link');
}

onTabArrowDownKey(event) {
if (!this.isInput(event) && !this.isTextArea(event)) {
if (this.focusedElementIsAccordionHeader()) {
const nextHeaderAction = this.findNextHeaderAction(event.target.parentElement.parentElement.parentElement);
nextHeaderAction ? this.changeFocusedTab(nextHeaderAction) : this.onTabHomeKey(event);

Expand All @@ -486,7 +480,7 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
}

onTabArrowUpKey(event) {
if (!this.isInput(event) && !this.isTextArea(event)) {
if (this.focusedElementIsAccordionHeader()) {
const prevHeaderAction = this.findPrevHeaderAction(event.target.parentElement.parentElement.parentElement);
prevHeaderAction ? this.changeFocusedTab(prevHeaderAction) : this.onTabEndKey(event);

Expand Down

0 comments on commit bbb9bb2

Please sign in to comment.