Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Jun 13, 2024
1 parent 2c04020 commit 6a60ba8
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,22 +464,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) && this.focusedElementIsAccordionHeader()) {
if (this.focusedElementIsAccordionHeader()) {
const nextHeaderAction = this.findNextHeaderAction(event.target.parentElement.parentElement.parentElement);
nextHeaderAction ? this.changeFocusedTab(nextHeaderAction) : this.onTabHomeKey(event);

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

onTabArrowUpKey(event) {
if (!this.isInput(event) && !this.isTextArea(event) && this.focusedElementIsAccordionHeader()) {
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 6a60ba8

Please sign in to comment.