Skip to content

Commit

Permalink
fix(cdk/tree): cleanup tree-key-manager token
Browse files Browse the repository at this point in the history
Change how tree-key-manager token is provided. Provide default
TreeKeyManager at root. Remove provider from NgModule.
  • Loading branch information
zarend committed Oct 30, 2023
1 parent 93474c7 commit 53e500e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/cdk/a11y/key-manager/tree-key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyMana
}

/** Injection token that determines the key manager to use. */
export const TREE_KEY_MANAGER = new InjectionToken<TreeKeyManagerFactory<any>>('tree-key-manager');
export const TREE_KEY_MANAGER = new InjectionToken<TreeKeyManagerFactory<any>>('tree-key-manager', {
providedIn: 'root',
factory: TREE_KEY_MANAGER_FACTORY,
});

/** @docs-private */
export function TREE_KEY_MANAGER_FACTORY<T extends TreeKeyManagerItem>(): TreeKeyManagerFactory<T> {
Expand Down
2 changes: 0 additions & 2 deletions src/cdk/tree/tree-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import {TREE_KEY_MANAGER_FACTORY_PROVIDER} from '@angular/cdk/a11y';
import {NgModule} from '@angular/core';
import {CdkTreeNodeOutlet} from './outlet';
import {CdkTreeNodePadding} from './padding';
Expand All @@ -28,6 +27,5 @@ const EXPORTED_DECLARATIONS = [
@NgModule({
exports: EXPORTED_DECLARATIONS,
declarations: EXPORTED_DECLARATIONS,
providers: [TREE_KEY_MANAGER_FACTORY_PROVIDER],
})
export class CdkTreeModule {}
1 change: 1 addition & 0 deletions src/cdk/tree/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
import {
TREE_KEY_MANAGER,
TREE_KEY_MANAGER_FACTORY_PROVIDER,
TreeKeyManagerFactory,
TreeKeyManagerItem,
TreeKeyManagerOptions,
Expand Down
1 change: 0 additions & 1 deletion src/material/tree/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ng_module(
),
assets = [":tree.css"] + glob(["**/*.html"]),
deps = [
"//src/cdk/a11y",
"//src/cdk/collections",
"//src/cdk/tree",
"//src/material/core",
Expand Down
2 changes: 0 additions & 2 deletions src/material/tree/tree-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import {NgModule} from '@angular/core';

import {TREE_KEY_MANAGER_FACTORY_PROVIDER} from '@angular/cdk/a11y';
import {CdkTreeModule} from '@angular/cdk/tree';
import {MatCommonModule} from '@angular/material/core';
import {MatNestedTreeNode, MatTreeNodeDef, MatTreeNode} from './node';
Expand All @@ -31,6 +30,5 @@ const MAT_TREE_DIRECTIVES = [
imports: [CdkTreeModule, MatCommonModule],
exports: [MatCommonModule, MAT_TREE_DIRECTIVES],
declarations: MAT_TREE_DIRECTIVES,
providers: [TREE_KEY_MANAGER_FACTORY_PROVIDER],
})
export class MatTreeModule {}

0 comments on commit 53e500e

Please sign in to comment.