From 3e4b1120d83ec04d530a3a5ee9e21736dfef4dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Wed, 12 Jun 2024 10:17:47 +0300 Subject: [PATCH] Fixed #15828 - Tree | Accessibility within Tree Component --- src/app/components/tree/tree.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/app/components/tree/tree.ts b/src/app/components/tree/tree.ts index 3a4f784e344..d65a9fe7ccf 100755 --- a/src/app/components/tree/tree.ts +++ b/src/app/components/tree/tree.ts @@ -638,7 +638,9 @@ export class UITreeNode implements OnInit { onEnter(event: KeyboardEvent) { this.tree.onNodeClick(event, this.node); this.setTabIndexForSelectionMode(event, this.tree.nodeTouched); - event.preventDefault(); + if (!(event.target instanceof HTMLElement && event.target.nodeName === 'A')) { + event.preventDefault(); + } } setAllNodesTabIndexes() { @@ -1155,12 +1157,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) {