Text input ignores value attribute
See original GitHub issueHey Jason, thanks for Preact, I love it!
I noticed a compatibility issue in Preact, when it behaves differently to React. The case is a simple component with input[type="text"]
inside. No event listeners, no updates, just a static component:
class TextInput extends Component {
render({ value }) {
return <input type="text" value={ value } />;
}
}
In React, input field ignores user input and remains empty (as it should). In Preact, input field accepts all user input.
Here are minimal test cases to compare Preact to React:
- Preact - http://www.webpackbin.com/NJ_pr2zYW
- React - http://www.webpackbin.com/EJthihMYW
Press “Save” button at the top to run the code.
Additional info: Preact version: 5.6.0
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:26 (14 by maintainers)
Top Results From Across the Web
React ignores value attribute of input field - Stack Overflow
Checkbox input value is the one sent in the request and not the text that appears afterwards. If you want it to be...
Read more >Text input ignores value attribute #263 - preactjs/preact - GitHub
Text input ignores value attribute. Preact basically has react's uncontrolled inputs model. This means the dom maintains the input's state, ...
Read more >HTML5 Forms: Value Attribute - Wufoo
The value attribute is not valid and ignored on the file input type. For select options, the value of the selected <option> gets...
Read more ><input type="text"> - HTML: HyperText Markup Language | MDN
The value attribute is a string that contains the current value of the text entered into the text field. You can retrieve this...
Read more >AngularJS - Value attribute on an input text box is ignored ...
Using AngularJS if I set a simple input text box value to something like "bob" below. The value does not display if the...
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
@deadlyicon I think the issue you posted above should be fixed in Preact X (gave it a quick glance)
Attach an
onkeydown
listener. If it’s not a space, update the state. Updating the state will then update your input value.