Repository navigation
Add wui.Keyed for stable row identity in the browser - #23
Merged
Merged
Conversation
Keyed(key, el) gives a child an identity the patching renderer matches on, so inserting at the front of a keyed list moves the existing rows and inserts one instead of re-patching every row. List items carry their Keyed child's key onto the <li>. Keyed is transparent everywhere else: no markup, Box reads Grow and MinWidth through it, a keyed Flex still stretches, and the TUI renders the child unchanged. The TUI focus and form-value walkers now recurse through Children for container types, so wrappers like Keyed need no case of their own. Closes #21
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
Implements #21.
wui.Keyed(key, el)giveselan identity the patching renderer (Patch the DOM instead of replacing it on every render #19) matches on. Inserting at the front of a keyed list moves the existing row nodes and creates one, instead of re-patching every row from the insertion point down. Per-row browser state stays with its row.Keyedchild's key onto the<li>, since that wrapper is the node being matched.styleOfreads through it, so a Box still sees the child'sGrow/MinWidth; a keyedFlex()still stretches (newunkeyedhelper for the TUI's spacer checks); the TUI renders the child unchanged.Children()for container types instead of listing each one, soKeyed(and any future wrapper) needs no case there.Test plan
TestKeyedRowsMoveInsteadOfRepatching: after prepending a row, the existing rows' DOM nodes are the same objects (marker survives) and the order is right. It failed before list items took their child's key.go test ./...,make e2e, both vetsCloses #21