|
1 |
| -import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; |
| 1 | +import {async, ComponentFixture, fakeAsync, TestBed, tick, inject} from '@angular/core/testing'; |
2 | 2 | import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms';
|
3 | 3 | import {Component, DebugElement, ViewChild} from '@angular/core';
|
4 | 4 | import {By} from '@angular/platform-browser';
|
5 | 5 | import {dispatchFakeEvent} from '@angular/cdk/testing/private';
|
| 6 | +import {FocusMonitor} from '@angular/cdk/a11y'; |
6 | 7 |
|
7 | 8 | import {MAT_RADIO_DEFAULT_OPTIONS} from './radio';
|
8 | 9 | import {MatRadioButton, MatRadioChange, MatRadioGroup, MatRadioModule} from './index';
|
@@ -387,6 +388,21 @@ describe('MatRadio', () => {
|
387 | 388 | expect(radioNativeElements[2].classList).toContain('mat-warn');
|
388 | 389 | });
|
389 | 390 |
|
| 391 | + it('should not manually move focus to underlying input when focus comes from mouse or touch', |
| 392 | + inject([FocusMonitor], (focusMonitor: FocusMonitor) => { |
| 393 | + const radioElement = radioNativeElements[0]; |
| 394 | + const inputElement = radioInputElements[0]; |
| 395 | + expect(document.activeElement).not.toBe(inputElement); |
| 396 | + |
| 397 | + focusMonitor.focusVia(radioElement, 'mouse'); |
| 398 | + fixture.detectChanges(); |
| 399 | + expect(document.activeElement).not.toBe(inputElement); |
| 400 | + |
| 401 | + focusMonitor.focusVia(radioElement, 'touch'); |
| 402 | + fixture.detectChanges(); |
| 403 | + expect(document.activeElement).not.toBe(inputElement); |
| 404 | + })); |
| 405 | + |
390 | 406 | });
|
391 | 407 |
|
392 | 408 | describe('group with ngModel', () => {
|
|
0 commit comments