Angular PrimeNG Tree – handle single-click and double-click on the same node (open vs. expand...

Discussão em 'Angular' iniciado por Abishek, Maio 27, 2025.

  1. Abishek

    Abishek Guest

    Problem
    I’m using the PrimeNG <p-tree> component (Angular 17, PrimeNG 17.0.1).
    I’d like:


    • single-click → show the node’s details in a side panel (i.e., “open” the node)


    • double-click → expand or collapse that node in the tree

    <p-tree> exposes events such as nodeSelect, nodeExpand, nodeCollapse, etc., but there’s no dedicated double-click handler and I can’t get (dblclick) to fire reliably on the node element.

    Question


    • Is there a built-in way in PrimeNG Tree to distinguish single-click from double-click on the same node?


    • If not, what’s the recommended workaround (custom template, directive, timer-based approach, etc.) that won’t break keyboard accessibility?

    <!-- app.component.html -->
    <p-tree
    [value]="files"
    selectionMode="single"
    (nodeSelect)="onNodeSelect($event)" <!-- single-click -->
    (dblclick)="onNodeDblClick($event)">
    </p-tree>


    I don't see any possible solutions for this

    Continue reading...

Compartilhe esta Página