test(e2e): tab selection survives a state-triggered rerun#48
test(e2e): tab selection survives a state-triggered rerun#48sudo-vaibhav wants to merge 1 commit into
Conversation
Adds a /tabs demo page (2-tab layout, text_input in tab 2) and an e2e spec pinning that a rerun ordered from inside tab 2 keeps tab 2 active. The active tab is uncontrolled Radix state on a stable-keyed component, so the tree patch from a rerun must not snap the user back to tab 1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughA new ChangesTabs Demo Page and E2E Test
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Knip dead-code gate — no regressions
All counts at or below baseline. |
size-limit report 📦
|
What
Adds an e2e test proving that tab selection sticks across a rerun when the rerun is ordered by a state change inside a tab.
examples/demo/src/pages/tabs.ts— new/tabsdemo page. A 2-tab layout where tab 2 owns atext_input; committing it reruns the script. Each tab echoes its own state so the spec can confirm the rerun actually fired.main.ts, export inpages/index.ts.e2e/tabs.spec.ts— the spec: default on tab 1 → switch to tab 2 → fill input → Enter → assert the echo updates (rerun landed) and tab 2 is stilldata-state="active"while tab 1 isinactive. Since Radix unmounts inactive tab content, the input staying visible is an independent confirmation tab 2 held.Why it sticks
The active tab is uncontrolled Radix state (
Tabs defaultValue="0"). On rerun the client patches the tree into a new object ref, butFramerenders every node with a stablekey={path}— the tabs path is unchanged, so React preserves the instance and Radix's selection survives. No remount → no snap-back to tab 1. The genuine corner case (the active tab disappears as a result of the state change) would legitimately remount and reset; that's out of scope and noted in the page comment.Verification
tabs.spec.ts: 2 passedsidebar.spec.ts+smoke.spec.ts(guard against the new nav link breaking counts): 11 passed🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests