From 338cd7bf30a7d534323218e8663aa60e81162b7f Mon Sep 17 00:00:00 2001 From: Shraddhameduri Date: Tue, 9 Jun 2026 19:53:07 -0400 Subject: [PATCH] fix(material/form-field): allow empty control properties --- src/material/chips/chip-grid.ts | 6 +++--- src/material/chips/chip-input.ts | 2 +- src/material/chips/chip-text-control.ts | 2 +- src/material/form-field/form-field-control.ts | 4 ++-- src/material/input/input.ts | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/material/chips/chip-grid.ts b/src/material/chips/chip-grid.ts index 828e2e7ea779..05c842cfabf3 100644 --- a/src/material/chips/chip-grid.ts +++ b/src/material/chips/chip-grid.ts @@ -155,14 +155,14 @@ export class MatChipGrid * @docs-private */ @Input() - get placeholder(): string { + get placeholder(): string | null | undefined { return this._chipInput ? this._chipInput.placeholder : this._placeholder; } - set placeholder(value: string) { + set placeholder(value: string | null | undefined) { this._placeholder = value; this.stateChanges.next(); } - protected _placeholder = ''; + protected _placeholder: string | null | undefined = ''; /** Whether any chips or the matChipInput inside of this chip-grid has focus. */ override get focused(): boolean { diff --git a/src/material/chips/chip-input.ts b/src/material/chips/chip-input.ts index 314da69b8208..d8b86a090569 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -104,7 +104,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy { readonly chipEnd: EventEmitter = new EventEmitter(); /** The input's placeholder text. */ - @Input() placeholder: string = ''; + @Input() placeholder: string | null | undefined = ''; /** Unique id for the input. */ @Input() id: string = inject(_IdGenerator).getId('mat-mdc-chip-list-input-'); diff --git a/src/material/chips/chip-text-control.ts b/src/material/chips/chip-text-control.ts index da91c1958695..bd97220cf9f9 100644 --- a/src/material/chips/chip-text-control.ts +++ b/src/material/chips/chip-text-control.ts @@ -12,7 +12,7 @@ export interface MatChipTextControl { id: string; /** The text control's placeholder text. */ - placeholder: string; + placeholder: string | null | undefined; /** Whether the text control has browser focus. */ focused: boolean; diff --git a/src/material/form-field/form-field-control.ts b/src/material/form-field/form-field-control.ts index 4454c7f534f7..99abf463e1c0 100644 --- a/src/material/form-field/form-field-control.ts +++ b/src/material/form-field/form-field-control.ts @@ -26,7 +26,7 @@ export abstract class MatFormFieldControl { readonly id!: string; /** The placeholder for this control. */ - readonly placeholder!: string; + readonly placeholder?: string | null; /** Gets the AbstractControlDirective for this control. */ readonly ngControl: NgControl | AbstractControlDirective | null = null; @@ -41,7 +41,7 @@ export abstract class MatFormFieldControl { readonly shouldLabelFloat: boolean = false; /** Whether the control is required. */ - readonly required: boolean = false; + readonly required?: boolean; /** Whether the control is disabled. */ readonly disabled: boolean = false; diff --git a/src/material/input/input.ts b/src/material/input/input.ts index d0ba16102861..e5d63c303c56 100644 --- a/src/material/input/input.ts +++ b/src/material/input/input.ts @@ -187,7 +187,7 @@ export class MatInput * Implemented as part of MatFormFieldControl. * @docs-private */ - @Input() placeholder!: string; + @Input() placeholder: string | null | undefined; /** * Name of the input.