Skip to content

Commit 1faed45

Browse files
committed
fix(cdk/tree): change inputs back to regular @input
1 parent 4ff7dcb commit 1faed45

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/cdk/tree/tree.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,28 @@ export class CdkTree<T, K = T>
300300
* relative to the function to know if a node should be added/removed/moved.
301301
* Accepts a function that takes two parameters, `index` and `item`.
302302
*/
303-
readonly trackBy = input<TrackByFunction<T>>();
303+
@Input()
304+
set trackBy(trackBy: TrackByFunction<T>) {
305+
this._trackBy.set(trackBy);
306+
}
307+
get trackBy(): TrackByFunction<T>|undefined {
308+
return this._trackBy();
309+
}
304310

305311
/**
306312
* Given a data node, determines the key by which we determine whether or not this node is expanded.
307313
*/
308-
readonly expansionKey = input<(dataNode: T) => K>();
314+
@Input()
315+
set expansionKey(expansionKey: (dataNode: T) => K) {
316+
this._expansionKey.set(expansionKey);
317+
}
318+
get expansionKey(): ((dataNode: T) => K)|undefined {
319+
return this._expansionKey();
320+
}
321+
322+
private readonly _trackBy = signal<TrackByFunction<T>|undefined>(undefined);
323+
324+
private readonly _expansionKey = signal<((dataNode: T) => K)|undefined>(undefined);
309325

310326
// Outlets within the tree's template where the dataNodes will be inserted.
311327
@ViewChild(CdkTreeNodeOutlet, {static: true}) _nodeOutlet: CdkTreeNodeOutlet;
@@ -356,10 +372,10 @@ export class CdkTree<T, K = T>
356372
// - if an expansionKey is provided, TS will infer the type of K to be
357373
// the return type.
358374
// - if it's not, then K will be defaulted to T.
359-
return this.expansionKey() ?? ((item: T) => item as unknown as K);
375+
return this._expansionKey() ?? ((item: T) => item as unknown as K);
360376
});
361377
readonly _trackByFn = computed(() => {
362-
const trackBy = this.trackBy();
378+
const trackBy = this._trackBy();
363379
if (trackBy) return trackBy;
364380
const expansionKey = this._expansionKeyFn();
365381
// Provide a default trackBy based on `_ExpansionKey` if one isn't provided.

0 commit comments

Comments
 (0)