From 6dd86edb3fbee4c3b7797aff2aea01c2ff44f340 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Mon, 17 Jan 2022 08:55:58 +0100 Subject: [PATCH] refactor(angular/input): inconsistently reading name from input with ngModel (#19233) If an input has a `name` binding and an `ngModel`, the input harness won't be able to read the name from the DOM, because `ngModel` doesn't proxy it. These changes add the proxy behavior to the `MatInput` directive, similarly to what we we're doing for `required`, `placeholder`, `readonly` etc. https://github.com/angular/components/pull/19233 --- src/angular/input/input.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/angular/input/input.ts b/src/angular/input/input.ts index a9a8a578c6..e4d84fcae9 100644 --- a/src/angular/input/input.ts +++ b/src/angular/input/input.ts @@ -61,6 +61,7 @@ const _SbbInputBase = mixinErrorState( '[attr.id]': 'id', '[disabled]': 'disabled', '[required]': 'required', + '[attr.name]': 'name || null', '[attr.readonly]': 'readonly && !_isNativeSelect || null', // Only mark the input as invalid for assistive technology if it has a value since the // state usually overlaps with `aria-required` when the input is empty and can be redundant. @@ -143,6 +144,12 @@ export class SbbInput */ @Input() placeholder: string; + /** + * Name of the input. + * @docs-private + */ + @Input() name: string; + /** * Implemented as part of SbbFormFieldControl. * @docs-private