Skip to content

Commit 3c5a152

Browse files
committed
fix(textarea): add a check for ElementInternals setFormValue for tests
1 parent 0e4dee8 commit 3c5a152

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/components/textarea/textarea.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ export class Textarea implements ComponentInterface {
149149
*/
150150
@Prop() disabled = false;
151151

152+
/**
153+
* Update element internals when disabled prop changes
154+
*/
152155
@Watch('disabled')
153156
protected disabledChanged() {
154157
this.updateElementInternals();
@@ -310,7 +313,7 @@ export class Textarea implements ComponentInterface {
310313
}
311314

312315
/**
313-
* Update validation state when required prop changes
316+
* Update native input and element internals when required prop changes
314317
*/
315318
@Watch('required')
316319
protected requiredChanged() {
@@ -599,7 +602,11 @@ export class Textarea implements ComponentInterface {
599602
// Disabled form controls should not be included in form data
600603
// Pass null to setFormValue when disabled to exclude it from form submission
601604
const value = this.disabled ? null : this.getValue();
602-
this.internals.setFormValue(value);
605+
// ElementInternals may not be fully available in test environments
606+
// so we need to check if the method exists before calling it
607+
if (typeof this.internals.setFormValue === 'function') {
608+
this.internals.setFormValue(value);
609+
}
603610
reportValidityToElementInternals(this.nativeInput, this.internals);
604611
}
605612

0 commit comments

Comments
 (0)