Skip to content

DateInputComponent throws TypeError in ngAfterViewInit when used with [formField] (signal forms) instead of Reactive Forms #4988

Description

@gordeevladislav

Description

When using kendo-dateinput together with the new [formField] binding (Angular signal-based forms) instead of a Reactive Forms FormControl, the component throws an unhandled TypeError during initialization:

TypeError: Cannot read properties of undefined (reading 'subscribe')

Root cause

In DateInputComponent.ngAfterViewInit, the following line assumes this.formControl is always a Reactive Forms FormControl (or null), and unconditionally accesses .statusChanges:

this.subs.add(this.formControl?.statusChanges.subscribe(() => this.setAriaInvalid()));

The optional chaining (?.) only guards against this.formControl itself being null/undefined — it does not guard against this.formControl existing but statusChanges being undefined. When the component is bound via [formField] instead of [formControl]/formControlName, this.formControl.statusChanges is undefined, so .subscribe(...) is called on undefined and throws.

Steps To Reproduce

  1. Create a component using Angular signal forms with [formField].
  2. Bind kendo-dateinput to that field via [formField] instead of a Reactive Forms FormControl.
  3. Load the component.

Screenshots or video

Image

Actual Behavior

Component throws TypeError: Cannot read properties of undefined (reading 'subscribe') at runtime, breaking initialization.

Expected Behavior

DateInputComponent should not throw when used with [formField]. Either:

  • Guard the subscription with a check for statusChanges existing (e.g. this.formControl?.statusChanges?.subscribe(...)), or
  • Detect the binding type and use the appropriate mechanism to react to validity/status changes for signal-based forms.

Browser

Chrome

Browser version

latest

OS type

MacOS, Windows

OS version

No response

Last working version of the Kendo UI for Angular package (if regression).

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions