Skip to content

Conversation

@nesgarbo
Copy link
Contributor

@nesgarbo nesgarbo commented Dec 5, 2025

Fix: Textarea throws error when used with Angular 21 Signal Forms

This PR fixes an incompatibility between PrimeNG’s Textarea component and Angular 21’s new Signal Forms.
When using Signal Forms, NgControl.valueChanges is undefined, causing the following runtime error inside Textarea.onInit():

ERROR TypeError: can't access property "subscribe", this.ngControl.valueChanges is undefined
   at onInit (primeng-textarea.mjs:175)
   at ngOnInit (primeng-basecomponent.mjs:205)

Root cause

valueChanges does not exist on Signal-based controls.
PrimeNG’s Textarea attempts to always subscribe to:
this.ngControl.valueChanges.subscribe(...)
This works for classic Reactive Forms but fails for Signal Forms because Angular 21 removed this observable for signal-based controls.

What this PR changes

The PR updates the condition to safely check whether valueChanges exists before subscribing:

if (this.ngControl?.valueChanges) {
   this.ngControlSubscription = (this.ngControl as any).valueChanges.subscribe(() => {
       this.updateState();
   });
}

This ensures compatibility with both:
Angular classic forms (which still expose valueChanges)
Angular Signal Forms (where valueChanges is undefined)

Why this fix is needed

Without this fix, any Angular 21 application using:
PrimeNG Textarea
Angular Signal Forms (formControl or formGroup with signals)
…will immediately throw a runtime error and break component rendering.

Issue reference
Fixes #19116

@vercel
Copy link

vercel bot commented Dec 5, 2025

@nesgarbo is attempting to deploy a commit to the cetincakiroglu's projects Team on Vercel.

A member of the Team first needs to authorize it.

@nesgarbo nesgarbo changed the title fix(#19116): Remove unnecesary suscription on signal forms Dec 5, 2025
@abishai53
Copy link

I need this change ASAP

@abishai53
Copy link

Do we have workarounds?

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

Labels

None yet

2 participants