fix(cc-search-bar): virtually focus the first result so Enter opens it - #1802
Open
clara-layus-cc wants to merge 1 commit into
Open
fix(cc-search-bar): virtually focus the first result so Enter opens it#1802clara-layus-cc wants to merge 1 commit into
clara-layus-cc wants to merge 1 commit into
Conversation
Pasting a resource id into the search bar yields a single result, but pressing `Enter` did nothing: the virtual focus started on the input (`_activeItemIndex` at `-1`) and was sent back there on every keystroke, while `Enter` only activates an item when the index is `0` or more. Reaching the only result took an `ArrowDown` first. The virtual focus now rests on the first filtered item instead of the input, which is what a command palette does and what the `↵` footer hint has been promising all along. It is reset by `willUpdate()` right after the filtered list is rebuilt, so it follows `value` and `sections` rather than being cleared by the input handler, and on close so that reopening with the same query starts over from the first item rather than from wherever the arrow keys left the selection. `updated()` no longer needs to catch an index pointing past the end of the list: the index is now derived from the filtered items every time they change, so it can no longer outlive them.
clara-layus-cc
requested review from
Galimede,
HeleneAmouzou,
florian-sanders-cc,
pdesoyres-cc and
roberttran-cc
August 21, 2026 12:55
Contributor
|
🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/fix/search-bar-select-first-result/index.html. This preview will be deleted once this PR is closed. |
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.
What does this PR do?
Enteropens a result right away — pasting a resource id and hittingEnternow jumps to its single result,willUpdate(), right after the filtered list is rebuilt, so it followsvalueandsectionsinstead of being cleared on every keystroke by the input handler,updated(), now that the index is derived from the filtered items every time they change.How to review?