Skip to content

fix(autocomplete): reopening when clicking an option in IE #5172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/lib/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export const MD_AUTOCOMPLETE_VALUE_ACCESSOR: any = {
*/
export function getMdAutocompleteMissingPanelError(): Error {
return Error('Attempting to open an undefined instance of `md-autocomplete`. ' +
'Make sure that the id passed to the `mdAutocomplete` is correct and that ' +
'you\'re attempting to open it after the ngAfterContentInit hook.');
'Make sure that the id passed to the `mdAutocomplete` is correct and that ' +
'you\'re attempting to open it after the ngAfterContentInit hook.');
}

@Directive({
selector: 'input[mdAutocomplete], input[matAutocomplete],' +
'textarea[mdAutocomplete], textarea[matAutocomplete]',
'textarea[mdAutocomplete], textarea[matAutocomplete]',
host: {
'role': 'combobox',
'autocomplete': 'off',
Expand All @@ -78,7 +78,9 @@ export function getMdAutocompleteMissingPanelError(): Error {
'[attr.aria-activedescendant]': 'activeOption?.id',
'[attr.aria-expanded]': 'panelOpen.toString()',
'[attr.aria-owns]': 'autocomplete?.id',
'(focus)': 'openPanel()',
// Note: we use `focusin`, as opposed to `focus`, in order to open the panel
// a little earlier. This avoids issues where IE delays the focusing of the input.
'(focusin)': 'openPanel()',
'(input)': '_handleInput($event)',
'(blur)': '_onTouched()',
'(keydown)': '_handleKeydown($event)',
Expand Down
14 changes: 7 additions & 7 deletions src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('MdAutocomplete', () => {
expect(fixture.componentInstance.trigger.panelOpen)
.toBe(false, `Expected panel state to start out closed.`);

dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');
fixture.whenStable().then(() => {
fixture.detectChanges();

Expand Down Expand Up @@ -147,7 +147,7 @@ describe('MdAutocomplete', () => {
}));

it('should close the panel when input loses focus', async(() => {
dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');
fixture.detectChanges();

fixture.whenStable().then(() => {
Expand All @@ -161,7 +161,7 @@ describe('MdAutocomplete', () => {
}));

it('should close the panel when an option is clicked', async(() => {
dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');
fixture.detectChanges();

fixture.whenStable().then(() => {
Expand All @@ -177,7 +177,7 @@ describe('MdAutocomplete', () => {
}));

it('should close the panel when a newly created option is clicked', async(() => {
dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');
fixture.detectChanges();

fixture.whenStable().then(() => {
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('MdAutocomplete', () => {
});

it('should hide the panel when the options list is empty', async(() => {
dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');

fixture.whenStable().then(() => {
fixture.detectChanges();
Expand Down Expand Up @@ -1127,7 +1127,7 @@ describe('MdAutocomplete', () => {
fixture.detectChanges();

const input = fixture.debugElement.query(By.css('input')).nativeElement;
dispatchFakeEvent(input, 'focus');
dispatchFakeEvent(input, 'focusin');

fixture.whenStable().then(() => {
fixture.detectChanges();
Expand Down Expand Up @@ -1226,7 +1226,7 @@ describe('MdAutocomplete', () => {
let fixture = TestBed.createComponent(AutocompleteWithOnPushDelay);

fixture.detectChanges();
dispatchFakeEvent(fixture.debugElement.query(By.css('input')).nativeElement, 'focus');
dispatchFakeEvent(fixture.debugElement.query(By.css('input')).nativeElement, 'focusin');
tick(1000);
fixture.detectChanges();

Expand Down