Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textarea with hydration (Angular v17) #3824

Closed
its-dibo opened this issue Nov 24, 2023 · 4 comments
Closed

textarea with hydration (Angular v17) #3824

its-dibo opened this issue Nov 24, 2023 · 4 comments
Labels

Comments

@its-dibo
Copy link

its-dibo commented Nov 24, 2023

when adding a textarea field, I got this error

main.ts:5 ERROR Error: NG0500: During hydration Angular expected a text node but the node was not found.

Angular expected this DOM:

<textarea rows="1" matinput="" class="mat-mdc-input-elementcdk-textarea-autosize" ng-reflect-id="formly_5_textarea_contacts_2" ng-reflect-required="true" ng-reflect-form="[objectObject]" ng-reflect-error-state-matcher="[objectObject]" cols="100" ng-reflect-field="[objectObject]" ng-reflect-placeholder="" tabindex="0" id="formly_5_textarea_contacts_2" required="" aria-required="true">
  #text(    )  <-- AT THIS LOCATION
  …
</textarea>

Note: attributes are only displayed to better represent the DOM but have no effect on hydration mismatches.

To fix this problem:
  * check the "FormlyFieldTextArea2" component for hydration-related issues
  * check to see if your template has valid HTML structure
  * or skip hydration by adding the `ngSkipHydration` attribute to its host node in a template

 Find more at https://angular.io/errors/NG0500
    at validateMatchingNode (core.mjs:18193:11)
    at locateOrCreateTextNodeImpl (core.mjs:25320:16)
    at ɵɵtext (core.mjs:25294:22)
    at FormlyFieldTextArea_Template (ngx-formly-material-textarea.mjs:46:12)
    at executeTemplate (core.mjs:11846:5)
    at renderView (core.mjs:14915:7)
    at renderComponent (core.mjs:14862:3)
    at renderChildComponents (core.mjs:14958:5)
    at renderView (core.mjs:14940:7)
    at ComponentFactory.create (core.mjs:15162:7)

field config:

 {
        key: 'contacts',
        type: 'textarea',
        props: {
          required: true,
          rows: 100,
          cols: 100,
        }
      }

image

important update
it seems that the first textarea field causes that the next select fields to be rendered wrong.
i.e. the drop-down doen't appear

@its-dibo its-dibo added the bug label Nov 24, 2023
@its-dibo
Copy link
Author

another issue related to this, is that <select> drop-down menu doesn't shown even it has field.props.options[]

@RaminGe
Copy link

RaminGe commented Dec 15, 2023

I had the same issue and the solution was really easy.

My code (broken):

<textarea [...]>
    </textarea>

Fixed:

<textarea [...]></textarea>

The whitespaces between the textarea texts resulted in the issue.

@its-dibo
Copy link
Author

its-dibo commented Jan 1, 2024

I use the built-in type textarea, not <textarea></textarea>

@aitboudad
Copy link
Member

This issue has been fixed and released as part of v6.3.0 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

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

No branches or pull requests

3 participants