Angualr mat-tree expand nodes on search

Discussão em 'Angular' iniciado por Creends, Janeiro 24, 2025.

  1. Creends

    Creends Guest

    I try to make a node selector using mat-autocomplete and mat-tree, with a search feature.

    When i click in the autocomplete input, it opens the panel and displays the mat-tree correctly. Then i can open and close nodes manually and select a node. The panel closes and the input displays the selected node path correctly. If i reopen the autocomplete, the tree is expanded to the selected node. If i type someting in the input, the tree is filtered to only display the matching data.

    What i want and can't figure out is how to expand the tree to the matching nodes during the search.

    I made a reproduction here where i try to achieve that : https://stackblitz.com/edit/stackblitz-starters-w82qymhw

    If you open the tree and manually select Banana then reopen, it is expanded as intended. But if you refresh, open the autocomplete and type "banana", it doesn't work.

    Continue reading...

Compartilhe esta Página