Skip to content

Commit

Permalink
Fixed primefaces#14368 - Accordian : TextArea shortcuts are not worki…
Browse files Browse the repository at this point in the history
…ng when used in Accordian Panels
  • Loading branch information
bhishman-desai committed Dec 30, 2023
1 parent e36ab22 commit 146364d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/app/components/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ChevronRightIcon } from 'primeng/icons/chevronright';
import { Subscription } from 'rxjs';
import { AccordionTabCloseEvent, AccordionTabOpenEvent } from './accordion.interface';
import { UniqueComponentId } from 'primeng/utils';
import { HTMLUtils } from '../utils/htmlutils';

/**
* AccordionTab is a helper component for Accordion.
Expand Down Expand Up @@ -463,17 +464,21 @@ export class Accordion implements BlockableUI, AfterContentInit, OnDestroy {
}

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

event.preventDefault();
event.preventDefault();
}
}

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

event.preventDefault();
event.preventDefault();
}
}

onTabHomeKey(event) {
Expand Down
11 changes: 11 additions & 0 deletions src/app/components/utils/htmlutils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class HTMLUtils {
public static isInput(event): boolean {
const { tagName } = event.target;
return tagName?.toLowerCase() === 'input';
}

public static isTextArea(event): boolean {
const { tagName } = event.target;
return tagName?.toLowerCase() === 'textarea';
}
}

0 comments on commit 146364d

Please sign in to comment.