List: selectedItemId can be briefly ignored on the very first render, even when set from the start (not just on later updates)
Description
List's selectedItemId can be momentarily ignored on a command's very first render - the native list briefly defaults to its own selection (the first row) before correcting itself to the requested selectedItemId, producing a visible flash.
This is distinct from #8622 (which is about a later update, e.g. a title change, resetting the selection): here it happens on the component's first-ever paint, when the data needed to compute selectedItemId is already available synchronously (for example via useCachedPromise's cache from a previous invocation), so selectedItemId is a real, correct value from the very first render - not something arriving after mount.
Where we observed it
In the Orion extension's Command Bar (@raycast/api ^1.104.9): opening the command with an empty search text focuses the tab currently visible in the browser. When cached tab data is already available on mount, opening the command visibly flashes to the first Open Tabs row before landing on the correct one.
What we ruled out
We instrumented the render path with logging and confirmed our own code is not the cause:
- Removed a fallback that supplied an early, best-guess
selectedItemIdbefore our own "wait for Raycast to acknowledge the selection" protection logic had run - on the theory that handing Raycast a real id on an unprotected first paint was the cause. The flash persisted. - Restructured our selection-tracking so the very first render is already in the "isolate to a single row" state our extension uses elsewhere to work around related selection issues (verified via logging: our render output is correctly isolated to just the target row from render #1 onward). The flash still happened.
Since our own render output is provably correct from the first frame in both cases, this looks like it's happening below the JS/React layer, in how the native List applies (or doesn't apply) an initial selectedItemId on its own first paint.
Related history
- API changelog, 1.53.0 (2023-06-07): "Fixed
selectedItemIdbeing sometimes ignored on the first render." - Same changelog, 1.84.0 (2024-10-09): "Fixed a regression where
selectedItemIdwouldn't be respected" - so this has regressed and been fixed at least twice already. - #8622 (open since 2023-09-30): same symptom family (list defaults to the first item despite a specified
selectedItemId), different trigger (a title update rather than initial mount).
Given the history of this specific behavior regressing more than once, this might be the same underlying issue resurfacing under a mount-time trigger rather than an update-time one. Happy to provide a minimal reproduction extension if that would help - our current repro is embedded in a larger extension (raycast/extensions#31601), so we wanted to describe the precise conditions first rather than guess at an untested minimal case.
Source: raycast/extensions