Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1773629
fix(cdk/tree): add test that demonstrates issue
BobobUnicorn Sep 16, 2024
37f75e9
fix(cdk/tree): signalize render pipeline
BobobUnicorn Sep 16, 2024
c0406a8
fix(cdk/tree): fix lint errors
BobobUnicorn Sep 17, 2024
9dcfa35
fix(cdk/tree): update API goldens
BobobUnicorn Sep 17, 2024
7b14b85
fix(cdk/tree): formatting
BobobUnicorn Sep 17, 2024
a31f246
fix(cdk/tree): update goldens
BobobUnicorn Sep 17, 2024
dda9c79
refactor(cdk/tree): make tests compiled, gets rid of one `detectChanges`
BobobUnicorn Sep 19, 2024
78cc5c0
refactor(cdk/tree): fold more data computation into signals
BobobUnicorn Sep 20, 2024
a9c989e
fix(cdk/tree): remove unnecessary `async`
BobobUnicorn Sep 20, 2024
856fdd1
fix(cdk/tree): revert to ng_test_library; ng_module tests don't work …
BobobUnicorn Oct 3, 2024
b9dab16
fix(cdk/tree): revert signal changes for tests
BobobUnicorn Oct 3, 2024
8ca9455
refactor(cdk/tree): signalify `_flattenedNodes`
BobobUnicorn Oct 3, 2024
d58e9d9
refactor(cdk/tree): signalify the data rendering
BobobUnicorn Oct 3, 2024
312b578
refactor(cdk/tree): signalify the trackBy/expansionKey functions
BobobUnicorn Oct 3, 2024
327d6ad
fix(cdk/tree): remove duplicate `detectChanges`
BobobUnicorn Oct 3, 2024
7358786
fix(cdk/tree): fix lints
BobobUnicorn Oct 3, 2024
68b29d9
fix(cdk/tree): tests
BobobUnicorn Nov 6, 2024
ae9c2f5
fix(cdk/tree): change inputs back to regular @Input
BobobUnicorn Nov 6, 2024
93a959b
fix(cdk/tree): update goldens, fix lints
BobobUnicorn Nov 7, 2024
49330bb
fix(cdk/tree): formatting
BobobUnicorn Nov 7, 2024
cb4edf0
fix(cdk/tree): api goldens, again
BobobUnicorn Nov 7, 2024
be104c2
fix(cdk/tree): lint
BobobUnicorn Nov 18, 2024
ecc4070
fix(cdk/tree): format
BobobUnicorn Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(cdk/tree): update goldens, fix lints
  • Loading branch information
BobobUnicorn committed Nov 18, 2024
commit 93a959bebd6917c7fafff9f8a7938b3fc66da968
15 changes: 6 additions & 9 deletions src/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class NodeOutletTemplateContext<T, K> {
/** @docs-private */
@Directive({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is private, do we need a separate component for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure of another way to hook into the onInit for the directive here, though I think ultimately removing mostRecentTreeNode would solve this issue (e.g. doing data passing through injection)

selector: '[cdkTreeNodeRenderer]',
standalone: true,
hostDirectives: [
{
directive: NgTemplateOutlet,
Expand Down Expand Up @@ -156,7 +155,6 @@ export class CdkTreeNodeRenderer<T, K> implements OnInit {
}
</ng-template>
`,
standalone: true,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [CdkTreeNodeRenderer],
Expand Down Expand Up @@ -189,7 +187,6 @@ export class CdkTreeNodeOutletTemplate<T, K> {
// declared elsewhere, they are checked when their declaration points are checked.
// tslint:disable-next-line:validate-decorators
changeDetection: ChangeDetectionStrategy.Default,
standalone: true,
imports: [CdkTreeNodeOutlet],
})
export class CdkTree<T, K = T>
Expand Down Expand Up @@ -302,23 +299,23 @@ export class CdkTree<T, K = T>
* Accepts a function that takes two parameters, `index` and `item`.
*/
@Input()
set trackBy(trackBy: TrackByFunction<T>) {
this._trackBy.set(trackBy);
}
get trackBy(): TrackByFunction<T>|undefined {
return this._trackBy();
}
set trackBy(trackBy: TrackByFunction<T>) {
this._trackBy.set(trackBy);
}

/**
* Given a data node, determines the key by which we determine whether or not this node is expanded.
*/
@Input()
set expansionKey(expansionKey: (dataNode: T) => K) {
this._expansionKey.set(expansionKey);
}
get expansionKey(): ((dataNode: T) => K)|undefined {
return this._expansionKey();
}
set expansionKey(expansionKey: (dataNode: T) => K) {
this._expansionKey.set(expansionKey);
}

private readonly _trackBy = signal<TrackByFunction<T>|undefined>(undefined);

Expand Down
10 changes: 7 additions & 3 deletions tools/public_api_guard/cdk/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export class CdkTree<T, K = T> implements AfterContentChecked, AfterContentInit,
expand(dataNode: T): void;
expandAll(): void;
expandDescendants(dataNode: T): void;
readonly expansionKey: InputSignal<((dataNode: T) => K) | undefined>;
set expansionKey(expansionKey: (dataNode: T) => K);
// (undocumented)
get expansionKey(): ((dataNode: T) => K) | undefined;
_getChildrenAccessor(): ((dataNode: T) => T[] | Observable<T[]> | null | undefined) | undefined;
_getDirectChildren(dataNode: T): Observable<T[]>;
// (undocumented)
Expand Down Expand Up @@ -125,7 +127,9 @@ export class CdkTree<T, K = T> implements AfterContentChecked, AfterContentInit,
_setNodeTypeIfUnset(newType: 'flat' | 'nested'): void;
toggle(dataNode: T): void;
toggleDescendants(dataNode: T): void;
readonly trackBy: InputSignal<TrackByFunction<T> | undefined>;
set trackBy(trackBy: TrackByFunction<T>);
// (undocumented)
get trackBy(): TrackByFunction<T> | undefined;
// (undocumented)
readonly _trackByFn: Signal<TrackByFunction<T>>;
// @deprecated
Expand All @@ -136,7 +140,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, AfterContentInit,
end: number;
}>;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<CdkTree<any, any>, "cdk-tree", ["cdkTree"], { "dataSource": { "alias": "dataSource"; "required": false; }; "treeControl": { "alias": "treeControl"; "required": false; }; "levelAccessor": { "alias": "levelAccessor"; "required": false; }; "childrenAccessor": { "alias": "childrenAccessor"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "expansionKey": { "alias": "expansionKey"; "required": false; "isSignal": true; }; }, {}, ["_nodeDefs"], never, true, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<CdkTree<any, any>, "cdk-tree", ["cdkTree"], { "dataSource": { "alias": "dataSource"; "required": false; }; "treeControl": { "alias": "treeControl"; "required": false; }; "levelAccessor": { "alias": "levelAccessor"; "required": false; }; "childrenAccessor": { "alias": "childrenAccessor"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "expansionKey": { "alias": "expansionKey"; "required": false; }; }, {}, ["_nodeDefs"], never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<CdkTree<any, any>, never>;
}
Expand Down