Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

search: Fix suggestion being selected after applying one#58186

Merged
fkling merged 3 commits into
mainfrom
fkling/57848-search-input-suggestion-selection
Nov 15, 2023
Merged

search: Fix suggestion being selected after applying one#58186
fkling merged 3 commits into
mainfrom
fkling/57848-search-input-suggestion-selection

Conversation

@fkling

@fkling fkling commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Fixes #57848

This issue occurred when a suggestion was applied while the extension was waiting for additional suggestions from the server.

There are various ways to fix this but the most robust one is to identify when a state update pertains to the current completion request and when it does not.

This commit adds a new field to the Query object to make this possible. Whenever a new request is issues this field is assigned a new value, making it easy to identify when we should preserve the current suggestion selection.

Test plan

A relatively reliable way to test this seems to be the following:

  • Prime file cache with some values, e.g. by typing file:foo
  • Add another file filter with a single letter which is different from the first letter used in the previous step (to ensure a server request is made). The point is to select an entry quickly from the cached results before the response from the server was received. E.g. f:o.
  • Use down arrow to select the first or second item and press enter
    -> The value gets inserted, the default suggestions are shown, none of the suggestions is selected.

@fkling fkling added the team/code-search Issues owned by the code search team label Nov 8, 2023
@fkling fkling requested a review from a team November 8, 2023 10:06
@fkling fkling self-assigned this Nov 8, 2023
@cla-bot cla-bot Bot added the cla-signed label Nov 8, 2023
@sourcegraph-bot

sourcegraph-bot commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@fkling fkling requested a review from vovakulikov November 9, 2023 19:08
Comment thread client/branded/src/search-ui/input/experimental/suggestionsExtension.ts Outdated
@fkling fkling force-pushed the fkling/57848-search-input-suggestion-selection branch from aadcee6 to 6aae1e4 Compare November 15, 2023 09:47
@fkling fkling enabled auto-merge (squash) November 15, 2023 09:48
This issue occurred when a suggestion was applied while the extension
was waiting for additional suggestions from the server.

There are various ways to fix this but the most robust one is to
identify when a state update pertains to the current completion request
and when it does not.

This commit adds a new field to the `Query` object to make this
possible. Whenever a new request is issues this field is assigned a new
value, making it easy to identify when we should preserve the current
suggestion selection.
@fkling fkling force-pushed the fkling/57848-search-input-suggestion-selection branch from 6aae1e4 to fc66150 Compare November 15, 2023 10:53
@fkling fkling merged commit eae9cd5 into main Nov 15, 2023
@fkling fkling deleted the fkling/57848-search-input-suggestion-selection branch November 15, 2023 11:15
vovakulikov pushed a commit that referenced this pull request Dec 12, 2023
This issue occurred when a suggestion was applied while the extension
was waiting for additional suggestions from the server.

There are various ways to fix this but the most robust one is to
identify when a state update pertains to the current completion request
and when it does not.

This commit adds a new field to the `Query` object to make this
possible. Whenever a new request is issues this field is assigned a new
value, making it easy to identify when we should preserve the current
suggestion selection.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed search-ux team/code-search Issues owned by the code search team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search input: completion then enter sometimes inserts a lang: filter

4 participants