NG-ZORRO/ng-zorro-antd

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

Opened this issue · 3 comments

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

this could be connected: angular/components#29595

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

It seems that issue have been resolved in version 18.2.2 of angular/components lib (https://github.com/angular/components/releases/tag/18.2.2 , angular/components#29648) . So in order to get rid of this error angular/components lib should be upgraded to version 18.2.2 or higher.