Skip to content

Commit ea008d7

Browse files
authored
test(material/select): remove form-field dependency in focus test (angular#21983)
The existing test would not work without using mat-form-field wrapper because when the click() method in the trigger is called, the event propagates to onContainerClick of FormField which calls focus() of select. With this addition, the logic does not base on propagating/onContainerClick but on a specific focus instruction.
1 parent 5a9ff9a commit ea008d7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/material-experimental/mdc-select/select.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,7 @@ describe('MDC-based MatSelect', () => {
30973097
const select = fixture.debugElement.nativeElement.querySelector('mat-select');
30983098

30993099
fixture.detectChanges();
3100+
select.focus(); // Focus manually since the programmatic click might not do it.
31003101
fixture.debugElement.query(By.css('.mat-mdc-select-trigger'))!.nativeElement.click();
31013102
fixture.detectChanges();
31023103
flush();

src/material/select/select.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,6 +3163,7 @@ describe('MatSelect', () => {
31633163
const select = fixture.debugElement.nativeElement.querySelector('mat-select');
31643164

31653165
fixture.detectChanges();
3166+
select.focus(); // Focus manually since the programmatic click might not do it.
31663167
fixture.debugElement.query(By.css('.mat-select-trigger'))!.nativeElement.click();
31673168
fixture.detectChanges();
31683169
flush();

0 commit comments

Comments
 (0)