Skip to content

Commit 5c3296f

Browse files
committed
fixup! fix(material/input): input harness selector not matching matNativeControl
Address feedback
1 parent 4abc82f commit 5c3296f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/material/input/testing/input-harness.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {InputHarnessFilters} from './input-harness-filters';
1212

1313
/** Harness for interacting with a standard Material inputs in tests. */
1414
export class MatInputHarness extends MatFormFieldControlHarness {
15-
static hostSelector = '.mat-input-element';
15+
// TODO: We do not want to handle `select` elements with `matNativeControl` because
16+
// not all methods of this harness work reasonably for native select elements.
17+
// For more details. See: https://github.com/angular/components/pull/18221.
18+
static hostSelector = '[matInput], input[matNativeControl]';
1619

1720
/**
1821
* Gets a `HarnessPredicate` that can be used to search for a `MatInputHarness` that meets

src/material/input/testing/shared.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ function getActiveElementTagName() {
195195
<mat-form-field>
196196
<input matNativeControl placeholder="Native control" id="nativeControl">
197197
</mat-form-field>
198+
199+
<mat-form-field>
200+
<!--
201+
Select native controls should not be handled as part of the input harness. We add this
202+
to assert that the harness does not accidentally match it.
203+
-->
204+
<select matNativeControl>
205+
<option value="first">First</option>
206+
</select>
207+
</mat-form-field>
198208
`
199209
})
200210
class InputHarnessTest {

0 commit comments

Comments
 (0)