NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.85k stars 3.9k forks source link

Tree view => Cannot read properties of undefined (reading 'value') #8708

Open Lavos96 opened 3 weeks ago

Lavos96 commented 3 weeks ago

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-ivy?file=package.json

Steps to reproduce

During initialization of tree-view component we get this error (there was no error in last version before 18 which is 17.4.1):

ERROR TypeError: Cannot read properties of undefined (reading 'value') at NzTreeViewComponent._initializeKeyManager (tree.mjs:492:46) at NzTreeViewComponent.ngAfterContentInit (tree.mjs:332:14) at callHookInternal (core.mjs:5150:14) at callHook (core.mjs:5177:13) at callHooks (core.mjs:5131:17) at executeInitAndCheckHooks (core.mjs:5081:9) at refreshView (core.mjs:13811:21) at detectChangesInView (core.mjs:13982:9) at detectChangesInViewIfAttached (core.mjs:13942:5) at detectChangesInComponent (core.mjs:13931:5)

If we get closer look at NzTreeViewComponent._initializeKeyManager, we see that:

const keyManagerOptions = { trackBy: node => this._getExpansionKey(node.data), skipPredicate: node => !!node.isDisabled, typeAheadDebounceInterval: true, horizontalOrientation: this._dir.value, <--- here we got error };

It is connected to unset Directionality, i dont know but this maybe should look like this in order to eliminate this error: this._dir?.value || 'ltr'

What is expected?

There should be no error in console

What is actually happening?

There is error in console

Environment Info
ng-zorro-antd 18.1.1
Browser Chrome
Lavos96 commented 3 weeks ago

this could be connected: https://github.com/angular/components/issues/29595

mcgorden commented 2 weeks ago

I met the same error too, and it blocks my work! Could you please provide a solution that works?