Skip to content

Commit

Permalink
fix(cdk/tree): avoid breaking change in constructor (#29648)
Browse files Browse the repository at this point in the history
In #29062 a new parameter was added to the `CdkTree` constructor which is a breaking change.

These changes switch to using `inject` which allows us to avoid the breaking change.

Fixes #29595.

(cherry picked from commit a6835ef)
  • Loading branch information
crisbeto committed Aug 27, 2024
1 parent f888b3d commit b1c5ed7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export class CdkTree<T, K = T>
OnDestroy,
OnInit
{
private _dir = inject(Directionality);

/** Subject that emits when the component has been destroyed. */
private readonly _onDestroy = new Subject<void>();

Expand Down Expand Up @@ -265,7 +267,6 @@ export class CdkTree<T, K = T>
constructor(
private _differs: IterableDiffers,
private _changeDetectorRef: ChangeDetectorRef,
private _dir: Directionality,
) {}

ngAfterContentInit() {
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/cdk/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class CdkNestedTreeNode<T, K = T> extends CdkTreeNode<T, K> implements Af

// @public
export class CdkTree<T, K = T> implements AfterContentChecked, AfterContentInit, AfterViewInit, CollectionViewer, OnDestroy, OnInit {
constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef, _dir: Directionality);
constructor(_differs: IterableDiffers, _changeDetectorRef: ChangeDetectorRef);
childrenAccessor?: (dataNode: T) => T[] | Observable<T[]>;
collapse(dataNode: T): void;
collapseAll(): void;
Expand Down

0 comments on commit b1c5ed7

Please sign in to comment.