fix(#19116): Textarea throws error when used with Angular 21 Signal Forms #19177
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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():
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:
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