|
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';
|
@@ -395,6 +396,21 @@ describe('MatRadio', () => {
|
395 | 396 | .every(element => element.classList.contains('mat-focus-indicator'))).toBe(true);
|
396 | 397 | });
|
397 | 398 |
|
| 399 | + it('should not manually move focus to underlying input when focus comes from mouse or touch', |
| 400 | + inject([FocusMonitor], (focusMonitor: FocusMonitor) => { |
| 401 | + const radioElement = radioNativeElements[0]; |
| 402 | + const inputElement = radioInputElements[0]; |
| 403 | + expect(document.activeElement).not.toBe(inputElement); |
| 404 | + |
| 405 | + focusMonitor.focusVia(radioElement, 'mouse'); |
| 406 | + fixture.detectChanges(); |
| 407 | + expect(document.activeElement).not.toBe(inputElement); |
| 408 | + |
| 409 | + focusMonitor.focusVia(radioElement, 'touch'); |
| 410 | + fixture.detectChanges(); |
| 411 | + expect(document.activeElement).not.toBe(inputElement); |
| 412 | + })); |
| 413 | + |
398 | 414 | });
|
399 | 415 |
|
400 | 416 | describe('group with ngModel', () => {
|
|
0 commit comments