Primeng: Vertical Trees can be forests, but horizontal Trees can't

Created on 27 Oct 2017  路  4Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

I'll also submitting pull request #4302 to fix this.

Plunkr Case (Bug Reports)

http://plnkr.co/edit/GRsvgNuh8iql4HzIK3I0?p=preview

Current behavior

Currently, if you show a Tree with more than one root (i.e. a forest) in vertical layout, it works as expected. However, if you switch to horizontal layout, only the first tree is shown.

Expected behavior

Vertical and horizontal layout should work the same, showing all trees of a forest.

Minimal reproduction of the problem with instructions

See Plunkr.

You can also use the PrimeNg Tree demo to see this. In the demo, the horizontal tree uses filesTree11, which has been set up with an additional single root element. If you set the tree attribute of the horizontal tree to filesTree10 instead of filesTree11, you only see the first of the three trees.

What is the motivation / use case for changing the behavior?

PrimeNG should behave more consistently. I want my users to be able to switch between the two layout modes. They would be surprised when in horizontal mode suddenly some trees are missing.

  • Angular version: 4.4.3

  • PrimeNG version: 4.3.0

  • Browser: all

  • Language: TypeScript 2.3.4

Most helpful comment

Please reconsider, as the fix is very simple and obvious, does not need additional code, and makes horizontal layout work the same as vertical. Otherwise, the fact that horizonzal trees have restrictions compared with vertical ones should be documented, because this is not what the user of the component expects. In my view this is a bug since the layout attribute should only affect how things are displayed, not which things are displayed.

One use case for me is a button that allows users switching from horizontal to vertical layout mode. It is not acceptable that when switching the layout mode, suddenly whole branches are missing.

Also note that my fix does not change anything in the case that the tree only has one root.

All 4 comments

No plans to support this, horizontal tree starts with a single root. If there is more demand, we'll reconsider, thank you.

Please reconsider, as the fix is very simple and obvious, does not need additional code, and makes horizontal layout work the same as vertical. Otherwise, the fact that horizonzal trees have restrictions compared with vertical ones should be documented, because this is not what the user of the component expects. In my view this is a bug since the layout attribute should only affect how things are displayed, not which things are displayed.

One use case for me is a button that allows users switching from horizontal to vertical layout mode. It is not acceptable that when switching the layout mode, suddenly whole branches are missing.

Also note that my fix does not change anything in the case that the tree only has one root.

+1

This change is definitely required to maintain consistency between horizontal and vertical trees.

+1, I proposed both layouts to my team, but now I have additional work to invest when switching from one to the other...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Faigjaz picture Faigjaz  路  3Comments

markgoho picture markgoho  路  3Comments

philly-vanilly picture philly-vanilly  路  3Comments

papiroca-tm picture papiroca-tm  路  3Comments

watalberto picture watalberto  路  3Comments