Repository navigation
Conversation
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.
Description
Closes #853
Problem
In
AssetFilter.tsx, managingfocusedIndexresets via effects with suppression comments introduced stale-closure risks and subtle desynchronization when the filtered asset list changed. While previous cleanup commits removed the effect, the search input'sonChangehandler omittedsetFocusedIndex(0), leaving keyboard focus on an arbitrary index after typing rather than resetting to the top search result.What Changed and Why it Removes Stale-Closure Risk
focusedIndexto0inside the search input'sonChangehandler and the clear-search button click handlers updates state synchronously in response to user input. This avoids any asynchronous effect cycle, eliminating stale closures and race conditions.effectiveFocusedIndex(Math.max(-1, Math.min(focusedIndex, filtered.length - 1))), ensuring the focused index never points out of bounds even if a list dynamically shrinks.eslint-disable react-hookscomments remain inAssetFilter.tsx.Acceptance Criteria Mapping
eslint-disable react-hookscomments inAssetFilter.tsxnpx eslint src/components/AssetFilter.tsx(0 errors, 0 warnings).setFocusedIndex(0)to the filter input'sonChangehandler inAssetFilter.tsx.AssetFilter.test.tsxcovers: focus resets on filter change"resets keyboard focus to index 0 on filter change (#853)"(moves focus down to index 2, types, and asserts index 0 is focused).AssetFilter.test.tsxcovers: arrow-key nav works after typing"allows arrow-key navigation after typing in filter (#853)"(types, navigates withArrowDown/ArrowUp, and verifies focused row and selection).How to Verify
npm test -- src/components/AssetFilter.test.tsx