ng-zorro-antd icon indicating copy to clipboard operation
ng-zorro-antd copied to clipboard

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

Open Lavos96 opened this issue 6 months ago • 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

Lavos96 avatar Aug 23 '24 07:08 Lavos96