Skip to content

Commit c668406

Browse files
committed
add focus method to button base
1 parent 59950b0 commit c668406

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/dev-app/mdc-button/mdc-button-demo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ import {Component} from '@angular/core';
1515
styleUrls: ['mdc-button-demo.css'],
1616
})
1717
export class MdcButtonDemo {
18+
isDisabled: boolean = false;
19+
clickCounter: number = 0;
20+
toggleDisable: boolean = false;
1821
}

src/material-experimental/mdc-button/button-base.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ export class MatButtonBase extends _MatButtonBaseMixin implements CanDisable, Ca
108108
}
109109
}
110110

111+
/** Focuses the button. */
112+
focus(): void {
113+
this._elementRef.nativeElement.focus();
114+
}
115+
111116
/** Gets whether the button has one of the given attributes. */
112117
private _hasHostAttributes(...attributes: string[]) {
113118
return attributes.some(attribute => this._elementRef.nativeElement.hasAttribute(attribute));
114119
}
115120
}
116121

117122
/** Shared inputs by buttons using the `<a>` tag */
118-
export const MAT_ANCHOR_INPUTS = MAT_BUTTON_INPUTS.concat(['tabIndex]']);
123+
export const MAT_ANCHOR_INPUTS = ['disabled', 'disableRipple', 'color', 'tabIndex'];
119124

120125
/** Shared host configuration for buttons using the `<a>` tag. */
121126
export const MAT_ANCHOR_HOST = {

0 commit comments

Comments
 (0)