feat(preprod): Navigate through snapshots with keyboard#110614
Merged
feat(preprod): Navigate through snapshots with keyboard#110614
Conversation
Comment on lines
139
to
141
| const handleSelectItem = (name: string) => { | ||
| setSelectedItemName(name); | ||
| setVariantIndex(0); |
Contributor
There was a problem hiding this comment.
Bug: When a search filters out the selected item, variantIndex is not reset. If the new auto-selected item has fewer variants, it can cause an out-of-bounds access, rendering nothing.
Severity: HIGH
Suggested Fix
Reintroduce a mechanism to reset the variantIndex to 0 whenever the currentItemName changes. This could be done with a useEffect hook that has currentItemName in its dependency array, calling setVariantIndex(0) within it. This ensures the variant index is always valid for the currently displayed item.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: static/app/views/preprod/snapshots/snapshots.tsx#L139-L141
Potential issue: When a user's search filters out the currently selected snapshot, the
view automatically selects the first item in the new filtered list. However, the
`variantIndex` from the previously selected item is not reset. If the new item has fewer
variants than the old `variantIndex`, the attempt to access
`selectedItem.images[variantIndex]` will be out-of-bounds. This results in
`currentImage` being `undefined`, causing the `SnapshotMainContent` component to return
`null` and render a blank screen until the user manually selects an item. This is caused
by the removal of a `useEffect` that previously reset the index.
Did we get this right? 👍 / 👎 to inform future reviews.
NicoHinderling
approved these changes
Mar 13, 2026
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.

Adds up/down arrow navigation. Resolves EME-948