Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15889 - Accessibility: Buttons within a Tree component can't b… #15890

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading