Commit ca8a75f
authored
fix: attach form submit listener before paint to prevent reload flake (#61)
test_form_no_page_reload could fail with render_count == 2 in CI. The Form
component attached its submit listener in React.useEffect, which runs *after*
the browser paints. That leaves a window after the form is rendered but before
the listener is wired, during which a submit falls through to the browser's
native GET submission - a full page reload that remounts the app and re-runs
the route component, bumping the render counter.
Attach the listener in useLayoutEffect instead, which runs synchronously
before paint, so the preventDefault handler is always in place by the time the
form is visible and interactive. This mirrors the Link preventDefault race
addressed for scroll restoration.1 parent d90b424 commit ca8a75f
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
137 | 143 | | |
138 | 144 | | |
139 | 145 | | |
| |||
0 commit comments