primefaces / primeng

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

Tree: Tree search stop on the first occurence on lenient mode #15190

Open LinkTheFirstFlame opened 8 months ago

LinkTheFirstFlame commented 8 months ago

Describe the bug

In lenient mode, the tree search result will not expand a folder that matches the search if it's child also matches the search too, whereas in strict mode it will show it. This problem could come from this line : https://github.com/primefaces/primeng/blob/eed5029014fc329901892a5014d66e8792d28d35/src/app/components/tree/tree.ts#L1625

Environment

Angular 17 application

Reproducer

No response

Angular version

17.2.2

PrimeNG version

17.12.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

10.1.0

Browser(s)

Chrome 123

Steps to reproduce the behavior

  1. Go on https://primeng.org/tree#filter
  2. In the example trees, search for "doc" in the leniant tree.
  3. In the strict tree search for "doc". The lenient tree will not display every matching node. tree-filter-bug

Expected behavior

In lenient mode, all result matching the search have to be visible.

kheos31 commented 7 months ago

Same problem for us, strict mode is too strict and cannot be used because it does not show nodes inside the folder which match the search, which is a classical request for users.

kheos31 commented 1 month ago

Hello. Could we have information about why the lenient mode is stopping the search of matching nodes at first element found? As said in previous comment, when a user wants to do a search, it's normal to visually show him all the results corresponding to his search, and if a folder is matching, it's understandable to show to the user these children. It seems to just be a normal user's expected goal..

Currently, lenient mode cannot make this goal possible because filteredNodes contains only the first results found.. We could just realize a second filter ourself, which doesn't seem like a good idea.

We're thinking to provide you a PR to let lenient mode searches into the entire tree, we would just appreciate an approvement for this idea.

Thanks in advance and have a nice day.