Repository navigation
fix(VirtualGrid): backport 1.7.3 initial-setup fixes to 1.6 - #102
Merged
Merged
Conversation
Brings src/primitives/VirtualGrid.tsx to its 1.7.3 state (B15 fixes from #72) and ports the matching contract tests: - an initial `selected` scrolls to its row and is applied once; the app's onSelectedChanged sees lastIdx === idx for that call, as with Row/Column - the node's `selected` is a child index into the window, set once, not the data index (autofocus with selected past the first window focused the wrong item; reactive selected back to row 0 left the grid scrolled) - last-row guard uses floor((count - 1) / perRow) - `this.selected` is written only when a child exists at the new index (a Down with nothing below lost the next Up) - one flex pass per window shift (layoutPending + onLayout wrapper, applyShift without a per-press closure) - `cursor` set in its own render effect instead of the props spread Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Backports the VirtualGrid fixes that reached 1.7 through #72 (B15) to the 1.6 line.
1.6.9already has the row-animation fix (#86); this adds the rest.src/primitives/VirtualGrid.tsxis now byte-identical to its1.7.3version.Ported (VirtualGrid only)
selectedscrolls to its row and is applied once (initialSelectedPending,forceRowScroll,applySelected). For that call the app'sonSelectedChangedgetslastIdx === idx, as Row and Column report a mount selection.selectedis now a child index into the window (max(0, props.selected - start()), set once with@once), not the data index. Before, autofocus withselected={10}focused item 16. Also, setting a reactiveselectedback to the first row left the grid scrolled 60px up.maxRows = floor((count - 1) / perRow). The old guard was one row late when the count is a multiple ofcolumns.this.selectedis written only when a child exists at the new index. Before, a Down with nothing below lost the next Up.layoutPendingflag, cleared by anonLayoutwrapper that still calls the app'sonLayout, andapplyShiftwith no closure per press.cursoris set in its owncreateRenderEffectinstead of in the props spread, so a press no longer re-reads every spread prop.Dependencies
None. 1.6 already has
lngp.chainRefsand nodeonLayoutsupport, and itsonLayoutcall semantics inupdateLayoutmatch 1.7.3. The 1.7.3 changes inwithScrolling.ts(renderer-v2 local caching) andhandleNavigation.ts(B1 wrap fix) are not needed by VirtualGrid, so they are not ported.Deliberately left out
Renderer 2.0 changes, TS7/oxlint tooling, and Virtual/Row/Column/Grid changes.
Virtual.tsxis untouched.Tests
tests/contract-virtual-grid.test.tsxnow matches its 1.7.3 version: 3BUG:skips are un-skipped as B15 tests, 2lastIdxexpectations are updated, and 8 tests are added (layout-pass count, cursor-spread probe, initialselectedwithout autofocus, items arriving after mount ×2, past the end, mountlastIdx×2).pnpm run build: passes.pnpm test: 36 files, 702 passed, 20 skipped, 1 todo. Baseline onorigin/1.6was 691 passed, 23 skipped, 1 todo.pnpm run lint: 0 errors, 157 warnings, the same as the baseline.🤖 Generated with Claude Code