Skip to content

nimble-tree-item briefly renders as selected if selected attribute is bound #2680

@kroeschl

Description

@kroeschl

🐛 Bug Report

When a new nimble-tree-item with the selected attribute bound is first rendered, the element will briefly be styled as if it's selected. This happens even if I hard-code [selected]="false".

Screencast.From.2025-08-05.15-31-59.mp4

💻 Repro or Code Sample

This is easiest to reproduce inside a cdk-virtual-scroll-viewport as shown above, but I was also able to reproduce it (though more briefly) with a regular ngFor and changing the size of its input array.

@Component()
class MyComponent {
    junkArray = [...Array(10000).keys()];
    ...
<cdk-virtual-scroll-viewport itemSize="32" style="height: 75vh">
    <nimble-tree-view>
        <nimble-tree-item *cdkVirtualFor="let i of junkArray; templateCacheSize: 0" [selected]="false">
            Item {{ i }}
        </nimble-tree-item>
    </nimble-tree-view>
</cdk-virtual-scroll-viewport>

Setting templateCacheSize: 0 makes this reproduce more consistently, but it still happens without that set.

🤔 Expected Behavior

The item should not be marked as selected.

😯 Current Behavior

The item is briefly styled as if it's selected, which makes for bad scrolling behavior in our case.

💁 Possible Solution

🤷 I'd be happy to contribute if someone can point me in the right direction.

🔦 Context

I'm migrating a vertical navigation list from a Bootstrap 3 (!) vertical pills-type thing to nimble-tree-view.

Image

🌍 Your Environment

  • OS & Device: Debian 13 PC
  • Browser: Reproduced with both Chrome 139.0.7258.31 and Firefox 140.0.4
  • Version: @ni/nimble-angular 30.1.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions