fix: respect view.selectedItemId after lazy-loaded items hydrate (#55)#65
Conversation
When a view uses ctx.data.loader() or ctx.data.staleWhileRevalidate() with a declared selectedItemId, the selection is evaluated against the current item set. If items haven't hydrated yet (empty array), selectedItemId resolves to empty, and when items later arrive the first item gets focus instead of the intended one. Fix: selectionAfterPatch() now checks next.selectedItemId (the view's declared intent) after patch-specific overrides but before falling back to the current selection or index 0. This ensures the view's declared focus target survives the item hydration cycle.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 25 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
When a view uses
ctx.data.loader()orctx.data.staleWhileRevalidate()with a declaredselectedItemId, the selection is evaluated against the current item set. If items haven't hydrated yet (empty array),selectedItemIdresolves to empty string, and when items later arrive the first item (items[0]) gets focus instead of the intended one.User-visible impact
Extensions that want to auto-focus a specific item (e.g., the current calendar event, the most recent screenshot) can't do it reliably with lazy-loaded data. The first item always gets focus on initial paint.
Root cause
selectionAfterPatch()insrc/App.tsx— called whenonViewHydrateoronViewPatchdelivers items — checks:patch.selectedItemId(explicit patch override — not set during hydration)selectedValueRef.current(which is''from the initial empty-items render)nextItems[0]?.id— bug: never checks the view's declaredselectedItemIdFix
Added a check for
next.selectedItemId(the view's declared intent) after patch-specific overrides but before falling back to current selection or index 0. This ensures the view's focus target survives the item hydration cycle.Change
src/App.tsx: 5 lines added toselectionAfterPatch()Acceptance
selectedItemIdis respected after lazy-loaded items hydrate viactx.data.loader()selectedItemIdis respected after stale-while-revalidate items hydrateCloses #55