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

Fix hydrating textarea with value prop #3891

Merged
merged 2 commits into from
Feb 14, 2023
Merged

Conversation

andrewiggins
Copy link
Member

If a component rendered <textarea value="Test" />, on the server we'd render <textarea>Test</textarea>, but on the client when hydrating, we'd remove the children of <textarea> since the component didn't specify any (textarea value="test" />). Further, since we don't set attributes or properties on hydration, the value property doesn't get applied either.

This PR fixes this behavior by adding a new hook to compat which checks if the VNode is a textarea and always applying the value if the DOM value doesn't match.

@coveralls
Copy link

coveralls commented Feb 10, 2023

Coverage Status

Coverage: 99.548% (+0.004%) from 99.543% when pulling aeb1e77 on hydrate-textarea into dec4d42 on master.

@github-actions
Copy link

github-actions bot commented Feb 10, 2023

Size Change: +204 B (0%)

Total Size: 54.2 kB

Filename Size Change
compat/dist/compat.js 3.88 kB +69 B (1%)
compat/dist/compat.module.js 3.81 kB +66 B (1%)
compat/dist/compat.umd.js 3.94 kB +69 B (1%)
ℹ️ View Unchanged
Filename Size Change
debug/dist/debug.js 3 kB 0 B
debug/dist/debug.module.js 3.01 kB 0 B
debug/dist/debug.umd.js 3.08 kB 0 B
devtools/dist/devtools.js 231 B 0 B
devtools/dist/devtools.module.js 240 B 0 B
devtools/dist/devtools.umd.js 314 B 0 B
dist/preact.js 4.23 kB 0 B
dist/preact.min.js 4.26 kB 0 B
dist/preact.min.module.js 4.26 kB 0 B
dist/preact.min.umd.js 4.28 kB 0 B
dist/preact.module.js 4.25 kB 0 B
dist/preact.umd.js 4.31 kB 0 B
hooks/dist/hooks.js 1.49 kB 0 B
hooks/dist/hooks.module.js 1.52 kB 0 B
hooks/dist/hooks.umd.js 1.57 kB 0 B
jsx-runtime/dist/jsxRuntime.js 360 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 326 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 441 B 0 B
test-utils/dist/testUtils.js 442 B 0 B
test-utils/dist/testUtils.module.js 444 B 0 B
test-utils/dist/testUtils.umd.js 526 B 0 B

compressed-size-action

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor question but feel free to merge

compat/src/render.js Outdated Show resolved Hide resolved
@andrewiggins andrewiggins merged commit b99c91c into master Feb 14, 2023
@andrewiggins andrewiggins deleted the hydrate-textarea branch February 14, 2023 18:50
andrewiggins added a commit that referenced this pull request Feb 28, 2023
* Fix hydrating textarea with value prop

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

Successfully merging this pull request may close these issues.

4 participants