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

defaultValue incorrectly (?) diffed against prerendered HTML #4340

Closed
1 task done
rschristian opened this issue Apr 18, 2024 · 0 comments · Fixed by #4341
Closed
1 task done

defaultValue incorrectly (?) diffed against prerendered HTML #4340

rschristian opened this issue Apr 18, 2024 · 0 comments · Fixed by #4341
Labels

Comments

@rschristian
Copy link
Member

rschristian commented Apr 18, 2024

  • Check if updating to the latest Preact version resolves the issue

Describe the bug

Rendering an input with defaultValue set runs into a bit of an issue with prerendered HTML as the HTML element will have value set (sincce there's no defaultValue attribute), but when Preact goes to diff it against the corresponding JS, it will clear out value and set defaultValue on the element. If only defaultValue were set this wouldn't be an issue, but explicitly clearing out value means defaultValue doesn't do much of anything (to my knowledge).

Fiddled with it a bit, but haven't found a decently golfed solution yet. Need some way to skip setting value or set value & defaultValue when defaultValue is incoming (I think).

Bit of a weird situation that can be solved by using value tbh.

Related: denoland/fresh#2406

To Reproduce

Reproduction

Steps to reproduce the behavior:

  1. Open repro
  2. Notice input is empty
  3. Check console to see that while the defaultValue prop is set, value is now an empty string.

Expected behavior

Like if the component was rendered w/out pre-existing HTML, the value should be correctly set so the input contains the right content.

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

Successfully merging a pull request may close this issue.

2 participants