Skip to content

Commit

Permalink
Fixed #15889 - Accessibility: Buttons within a Tree component can't b…
Browse files Browse the repository at this point in the history
…e activated via Keyboard
  • Loading branch information
mehmetcetin01140 committed Jun 24, 2024
1 parent 1a7c2cf commit 7632ab8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/app/components/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,19 @@ export class UITreeNode implements OnInit {
event.preventDefault();
}

isActionableElement(event) {
const target = event.target;

const isActionable = target instanceof HTMLElement && (target.nodeName == 'A' || target.nodeName == 'BUTTON');

return isActionable;
}

onEnter(event: KeyboardEvent) {
this.tree.onNodeClick(event, <TreeNode>this.node);
this.setTabIndexForSelectionMode(event, this.tree.nodeTouched);
if (!(event.target instanceof HTMLElement && event.target.nodeName === 'A')) {

if (!this.isActionableElement(event)) {
event.preventDefault();
}
}
Expand Down Expand Up @@ -1157,12 +1166,7 @@ export class Tree implements OnInit, AfterContentInit, OnChanges, OnDestroy, Blo

public dragStopSubscription: Subscription | undefined | null;

constructor(
public el: ElementRef,
@Optional() public dragDropService: TreeDragDropService,
public config: PrimeNGConfig,
private cd: ChangeDetectorRef
) {}
constructor(public el: ElementRef, @Optional() public dragDropService: TreeDragDropService, public config: PrimeNGConfig, private cd: ChangeDetectorRef) {}

ngOnInit() {
if (this.droppableNodes) {
Expand Down

0 comments on commit 7632ab8

Please sign in to comment.