Skip to content

Commit

Permalink
Merge pull request #15890 from primefaces/issue-15889
Browse files Browse the repository at this point in the history
Fixed #15889 - Accessibility: Buttons within a Tree component can't b…
  • Loading branch information
cetincakiroglu committed Jun 27, 2024
2 parents 9c6b547 + 7632ab8 commit efde544
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 efde544

Please sign in to comment.