Skip to content

feat(preprod): Navigate through snapshots with keyboard#110614

Merged
rbro112 merged 3 commits intomasterfrom
ryan/navigate_through_snapshots_with_keyboard
Mar 13, 2026
Merged

feat(preprod): Navigate through snapshots with keyboard#110614
rbro112 merged 3 commits intomasterfrom
ryan/navigate_through_snapshots_with_keyboard

Conversation

@rbro112
Copy link
Member

@rbro112 rbro112 commented Mar 13, 2026

Adds up/down arrow navigation. Resolves EME-948

@rbro112 rbro112 requested a review from a team as a code owner March 13, 2026 04:10
Copy link
Member Author

rbro112 commented Mar 13, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 13, 2026
Comment on lines 139 to 141
const handleSelectItem = (name: string) => {
setSelectedItemName(name);
setVariantIndex(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rbro112 rbro112 changed the title Navigate through snapshots with keyboard feat(preprod): Navigate through snapshots with keyboard Mar 13, 2026
@linear-code
Copy link

linear-code bot commented Mar 13, 2026

@rbro112 rbro112 merged commit 5b80806 into master Mar 13, 2026
63 checks passed
@rbro112 rbro112 deleted the ryan/navigate_through_snapshots_with_keyboard branch March 13, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants