primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
9.9k stars 4.51k forks source link

p-tree: p-button inside ng-template not visible when filter applied #12184

Open psarno opened 1 year ago

psarno commented 1 year ago

Describe the bug

When a p-tree component has an ng-template inside of it containing a button component, the button disappears if any filter is applied to the p-tree component.

Environment

Versions described below.

Reproducer

https://stackblitz.com/edit/github-s5vnkt

Angular version

14.2.9

PrimeNG version

14.2.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16.13.1

Browser(s)

No response

Steps to reproduce the behavior

  1. Expand a parent node
  2. Click on child node
  3. Note the "Next" button appears
  4. Refresh
  5. Apply a filter to the p-tree
  6. Do steps above, no "Next" button visible

Expected behavior

The p-button inside of the p-tree's ng-template should be rendered whether or not a filter is applied.

psarno commented 9 months ago

Has there been any activity on this issue?

We are now on PrimeNG 16.4.1 and this is still not working, and there are even more bizarre issues than that when you have a filter applied.

When the p-tree has a filter applied and the selection property is bound:

[(selection)]="selectedTreeNode"

This node does not represent the selection. If the selection is a child node, the selectedTreeNode gets set to the parent, which is not the actual selection.

We have bound the following event:

(onNodeSelect)="onNodeSelect($event)"

If I execute the following in this method:

console.log(this.selectedTreeNode);

The value returned is the parent. Meanwhile, the event itself was fired when selecting the child.

In looking through the properties of the parent node, there is no way to determine which child is actually selected, so we are stuck at that point.

It seems that if a child is selected, the selected node should be set to that child, not to its parent.