question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text input ignores value attribute

See original GitHub issue

Hey 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:

Press “Save” button at the top to run the code.

Additional info: Preact version: 5.6.0

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:26 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
JoviDeCroockcommented, Apr 14, 2020

@deadlyicon I think the issue you posted above should be fixed in Preact X (gave it a quick glance)

1reaction
lukeedcommented, Dec 18, 2017

Attach an onkeydown listener. If it’s not a space, update the state. Updating the state will then update your input value.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found