Mitosis react-like textarea syntax does not work in angular
See original GitHub issueI am interested in helping provide a fix!
Yes
Which generators are impacted?
- All
- Angular
- HTML
- Qwik
- React
- React-Native
- Solid
- Stencil
- Svelte
- Vue
- Web components
Reproduction case
Expected Behaviour
When using the react-like syntax to set the value of a textarea e.g
<textarea value='test' />
Mitosis converts this into the following angular code
<textarea value="test"></textarea>
Instead mitosis should convert this into one of the following syntaxes which works in angular.
<textarea [value]="'test'"></textarea>
<textarea [(ngModel)]="name"></textarea>
Actual Behaviour
<textarea value="test"></textarea>
does not show “test” inside the textarea in angular.
Additional Information
See stackblitz https://stackblitz.com/edit/angular-ivy-zar36q?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Issues · BuilderIO/mitosis - GitHub
Mitosis does not convert optional callbacks in angular to use @Output and ... Mitosis react-like textarea syntax does not work in angular bug...
Read more >Textarea does not work in Angular but Input works fine
I am trying to create a directive for text area, where I can show the number of characters remaining and clear the whole...
Read more >The Textarea element - HTML: HyperText Markup Language
This attribute enables you to place <textarea> elements anywhere within a document, not just as descendants of form elements. maxlength. The ...
Read more >Angular textarea Directive - W3Schools
AngularJS holds the current state of all textarea elements. Textarea fields have the following states: $untouched The field has not been touched yet ......
Read more >How to change the Content of a textarea using JavaScript
Method 1: This method uses id attribute of textarea with value property to change the content of <textarea> element. JavaScript code is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From what I see in regular html the text goes between the opening and closing textarea tag. That tag doesn’t have a “value” attribute like input does.
https://www.w3schools.com/react/react_forms.asp “The textarea element in React is slightly different from ordinary HTML” “In HTML the value of a textarea was the text between the start tag <textarea> and the end tag </textarea>”
I did link a stackblitz that shows the problem. Though if you use property binding in angular with the value attribute it does work…
I’ll look around see if I can find any better docs though.
Ok, we’d need to put together a list of how each framework handles
textarea
values to best decide what to do:value
prop: https://svelte.dev/tutorial/textarea-inputs[value]
or[(ngModel)]
bind:value
https://svelte.dev/tutorial/textarea-inputs:value
binding here: https://vuejs.org/guide/essentials/forms.htmlOnce this list is complete we can figure out the best thing to do.
It does seem like
textarea
’s value is a special case in almost all modern web frameworks, so it might make the most sense to allow avalue
field in Mitosis types, and make sure to give it a special mapping in each framework as expected.