Skip to content

Improve history item selection behavior

Created by: benvenker

Successful outcomes of this issue

  • When a history item is active or hovered on:
    • Populate the search input with the history as if it was selected by enter or tab in today's implementation
    • Place an active cursor in the search input at the end of the input content
  • If a search history item is clicked on with a mouse cursor or enter is pressed when the item is active, run the search directly

Background

There are two defaults we don't have in our search history, that are convention in both browser histories and search engine suggestions/history and which, if implemented, eliminate the tradeoffs being debated in the comments below:

  1. We don't populate the search input with the highlighted history item as you navigate through the history
  2. Because of 1. we can't (and so don't) put an active cursor at the end of item displayed in the input, making it possible and natural to both edit a search if desired or run it directly by pressing enter

Additionally, with the change in typeahead behavior to allow enter or tab to autocomplete suggestions, but the simultaneous removal of the first item's automatic selection, we now require the user to press the down arrow to first select a suggestion before completing it.

Video examples of browser history, Sourcegraph history, and Google search behavior


Previous issue content for posterity

  • Currently, when I click on a search history item, it populates the query but doesn't run the search.
  • When I click on enter with a search history item, it runs an empty search. I know this is because of existing suggestion behavior but in this context it's more confusing than normal.*

*I think this will be partially resolved by a recent PR from @fkling, but not sure if there's more implementation work required for history.