Skip to content

Commit 8b1d559

Browse files
committed
fix(cdk/tree): change inputs back to regular @input
1 parent f617f22 commit 8b1d559

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
@@ -301,12 +301,28 @@ export class CdkTree<T, K = T>
301301
* relative to the function to know if a node should be added/removed/moved.
302302
* Accepts a function that takes two parameters, `index` and `item`.
303303
*/
304-
readonly trackBy = input<TrackByFunction<T>>();
304+
@Input()
305+
set trackBy(trackBy: TrackByFunction<T>) {
306+
this._trackBy.set(trackBy);
307+
}
308+
get trackBy(): TrackByFunction<T>|undefined {
309+
return this._trackBy();
310+
}
305311

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

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

0 commit comments

Comments
 (0)