angular-tree-component icon indicating copy to clipboard operation
angular-tree-component copied to clipboard

scroll bar is visible even for small tree

Open debslab opened this issue 9 years ago • 3 comments

After upgrading to 3.1.0 version, I am seeing vertical scroll bar all the time even if the dataset is small. Please help me to resolve the issue

debslab avatar Mar 06 '17 09:03 debslab

Hi,

I confirm with this failing test case: https://plnkr.co/edit/mZTQ9xnikhMwoOvkfiLl?p=preview (Firefox 51, Chromium 56, zoom at 100%)

It looks like the <tree-viewport> gets a computed height that misses 1px per visible node…

ghybs avatar Mar 06 '17 11:03 ghybs

Looks like the height computation uses a hard-coded 22px as node-content-wrapper height (including the top and bottom 2px padding), but the text height looks to never be specified.

Therefore it depends on the current font-size (which is probably intended). Here is another failing test case that worsens the effect by increasing the font-size to 300%: https://plnkr.co/edit/dMeqCZugTXNogmZY5SfT?p=preview

The <tree-viewport> height is still set to 50px, even though the font size makes each node much taller.

A workaround looks to be to specify the nodeHeight option, to 25px in this case:

<tree-root
  [options]="{nodeHeight: 25}"
  [nodes]="nodes">
</tree-root>

https://plnkr.co/edit/MvtLcpvsMRnGOaPhJxmj?p=preview

All these computations look to have been introduced for the "virtualscroll" functionality. I guess its purpose it to enable virtual height, when nodes are lazy loaded? In that case, it is understandable that the node height must be explicitly specified, or at least read from an actual node so that it accounts for the font size.

It could also be interesting to provide an option to disable virtual scroll and get rid of any headache, for the numerous use cases where all nodes are loaded?

ghybs avatar Mar 06 '17 12:03 ghybs

Fixed in 3.2.1 - please upgrade

adamkleingit avatar Mar 07 '17 14:03 adamkleingit