From 154cd5967be1a83940f04b57fbb3b42e7ea9ba8c Mon Sep 17 00:00:00 2001 From: Zach Arend Date: Wed, 11 Oct 2023 20:54:53 +0000 Subject: [PATCH] refactor(material/tree): remove dead code around MatTreeNode#tabindex. remove dead code around MatTreeNode#tabinde. update code comments This commit message will be removed when squashing the cdk-tree-revamp brand. --- src/material/tree/node.ts | 34 ++++++++++--------------- tools/public_api_guard/material/tree.md | 3 --- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/material/tree/node.ts b/src/material/tree/node.ts index b4c7f08e730a..9c57c9f3d3c9 100644 --- a/src/material/tree/node.ts +++ b/src/material/tree/node.ts @@ -53,18 +53,20 @@ export class MatTreeNode /** * The tabindex of the tree node. * - * @deprecated This will be ignored; the tree will automatically determine the appropriate tabindex for the tree node. This input will be - * removed in a future version. - * @breaking-change 19.0.0 Remove this input + * @deprecated MatTreeNode ignores this proprety. Changing tabIndex has no affect. The tree + * automatically determines the appropriate tabindex for the tree node. To be removed in a + * future version. + * @breaking-change 19.0.0 Remove this attribute. */ tabIndex: number; /** * The tabindex of the tree node. * - * @deprecated This will be ignored; the tree will automatically determine the appropriate tabindex for the tree node. This input will be - * removed in a future version. - * @breaking-change 19.0.0 Remove this input + * @deprecated MatTreeNode ignores this proprety. Changing defaultTabIndex has no affect. The tree + * automatically determines the appropriate tabindex for the tree node. To be removed in a + * future version. + * @breaking-change 19.0.0 Remove this attribute. */ defaultTabIndex: number; @@ -85,10 +87,12 @@ export class MatTreeNode elementRef: ElementRef, tree: CdkTree, changeDetectorRef: ChangeDetectorRef, + // Ignore tabindex attribute. MatTree manages its own active state using TreeKeyManager. + // Keeping tabIndex in constructor for backwards compatibility with trees created before + // introducing TreeKeyManager. @Attribute('tabindex') tabIndex: string, ) { super(elementRef, tree, changeDetectorRef); - this.tabIndex = Number(tabIndex) || 0; } // This is a workaround for https://github.com/angular/angular/issues/23091 @@ -151,27 +155,17 @@ export class MatNestedTreeNode this.isDisabled = coerceBooleanProperty(value); } - /** - * The tabindex of the tree node. - * - * @deprecated This will be ignored; the tree will automatically determine the appropriate tabindex for the tree node. This input will be - * removed in a future version. - * @breaking-change 19.0.0 Remove this input - */ - get tabIndex(): number { - return Number(this._elementRef.nativeElement.getAttribute('tabindex') ?? '-1'); - } - set tabIndex(value: number) {} - constructor( elementRef: ElementRef, tree: CdkTree, differs: IterableDiffers, changeDetectorRef: ChangeDetectorRef, + // Ignore tabindex attribute. MatTree manages its own active state using TreeKeyManager. + // Keeping tabIndex in constructor for backwards compatibility with trees created before + // introducing TreeKeyManager. @Attribute('tabindex') tabIndex: string, ) { super(elementRef, tree, changeDetectorRef, differs); - this.tabIndex = Number(tabIndex) || 0; } // This is a workaround for https://github.com/angular/angular/issues/19145 diff --git a/tools/public_api_guard/material/tree.md b/tools/public_api_guard/material/tree.md index 1c9de8c1f81f..cbd5e4047349 100644 --- a/tools/public_api_guard/material/tree.md +++ b/tools/public_api_guard/material/tree.md @@ -45,9 +45,6 @@ export class MatNestedTreeNode extends CdkNestedTreeNode impleme ngOnInit(): void; // (undocumented) node: T; - // @deprecated - get tabIndex(): number; - set tabIndex(value: number); // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "mat-nested-tree-node", ["matNestedTreeNode"], { "role": { "alias": "role"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; "isExpandable": { "alias": "isExpandable"; "required": false; }; "isExpanded": { "alias": "isExpanded"; "required": false; }; "isDisabled": { "alias": "isDisabled"; "required": false; }; "node": { "alias": "matNestedTreeNode"; "required": false; }; }, { "activation": "activation"; "expandedChange": "expandedChange"; }, never, never, false, never>; // (undocumented)