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:
Kristiyan Kostadinov
2017-06-23 20:17:21 +02:00
committed by Jeremy Elbourn
parent c81e6088d1
commit 7b2d4ae601
2 changed files with 11 additions and 3 deletions
+8
View File
@@ -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', () => {
+3 -3
View File
@@ -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();
}