mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(select): expose focus method (#5255)
Exposes the `focus` method from `md-select` for consistency with `md-input-container`. Fixes #5251.
This commit is contained in:
committed by
Jeremy Elbourn
parent
c81e6088d1
commit
7b2d4ae601
@@ -1701,6 +1701,14 @@ describe('MdSelect', () => {
|
||||
subscription.unsubscribe();
|
||||
});
|
||||
|
||||
it('should be able to focus the select trigger', () => {
|
||||
document.body.focus(); // ensure that focus isn't on the trigger already
|
||||
|
||||
fixture.componentInstance.select.focus();
|
||||
|
||||
expect(document.activeElement).toBe(select, 'Expected select element to be focused.');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('for options', () => {
|
||||
|
||||
@@ -398,7 +398,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
|
||||
this._placeholderState = '';
|
||||
}
|
||||
|
||||
this._focusHost();
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,8 +753,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
|
||||
}
|
||||
}
|
||||
|
||||
/** Focuses the host element when the panel closes. */
|
||||
private _focusHost(): void {
|
||||
/** Focuses the select element. */
|
||||
focus(): void {
|
||||
this._elementRef.nativeElement.focus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user