fix: restore controlled form controls after onChange #116
Open
bilalvur(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/116/head·opened Showing 10 changed files with 11 additions and 1 deletion (loading 7).
x
@@ -0,0 +1,5 @@
+---
+'@tanstack/redact': patch
+---
+
+Restore a controlled input's, textarea's or select's rendered value, and a checkbox's or radio group's checked state, after its change handlers run, including after hydration. An edit, click or choice the app does not accept no longer stays in the DOM. ([#115](https://github.com/TanStack/redact/issues/115))
@@ -287,6 +287,9 @@
+ // Hydration skips the form syncs, which record props for controlled restores.
+ if (tag === 'input' || tag === 'textarea' || tag === 'select')
+ (candidate as any).__p = props;
@@ -1,11 +1,13 @@
+import { listenForRestores } from '../../form-controls';
- const { children } = fiber.v as {
+ const { children, container } = fiber.v as {