fix: Solid array item inputs lose focus and drop input after one keystroke - #101
Merged
Merged
Conversation
…em inputs
The ArrayWrapper called props.children({ items: items(), ... }) with the
memo read inside the tracked JSX expression. Immutable state updates
produce a new array reference on every keystroke, so the whole render-prop
subtree was torn down and recreated, destroying the active input after
one character. Expose items as a lazy getter and invoke the render prop
untracked so <Index>/<For> own the granular reactivity.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Critical Solid-binding bug found in a deep review: you can only type one character into any array item field.
ArrayWrappercalledprops.children({ items: items(), ... })with theitems()memo read inside the tracked JSX expression. Form state is immutable, so every keystroke produces a new array reference, invalidating the tracked expression — Solid tears down and recreates the entire item subtree, destroying the active<input>. TypingHelloleaves the field containingH.Fix
Expose
itemsas a lazy getter on the ops object and invoke the render prop once,untracked, so<Index>/<For>handle reactivity granularly instead of the whole subtree re-running.Tests
New
FormSolidArrayField.test.tsx: the typing regression (Red:expected 'H' to be 'Hello'before the fix, Green after) plus append/remove tests that pass both before and after, proving theuntrackdoes not regress add/remove reactivity. Full suite: 304 passed, types + lint clean.Found by: sharded deep review with mandatory executed Red→Green validation; independently re-validated (Red re-confirmed on clean main, Green after patch).