Skip to content

search: prevent the rendering of the home page when navigating back to the search results

Administrator requested to merge vb/search-scroll-restoration-1 into main

Created by: valerybugakov

Context

TLDR

We render the search home page when navigating back to search results from the blob view. Don't believe me? Go to the cloud instance, set a breakpoint in the SearchPage.tsx file in dev tools and try yourself!

Details

Currently, we have parsedSearchQuery in the state of the SourcegraphWebApp component.

  1. Upon opening search results — its value is updated with the current search query.
  2. After opening any search result — its value is set to an empty string.
  3. When we navigate back to search results we there's a delay in updating its value because:

Changes

  • This PR removes parsedSearchQuery from the state of the SourcegraphWebApp component.
    • It seems it's required only in the SourcegraphWebApp componentDidMount hook, and deleting it from the state doesn't break things.
  • Uses parsedSearchQuery directly from the Layout component that we already have in place.

As a result — the StreamingSearchResults component is rendered right away when navigating back to search results without redundant intermediate steps.

Preparation to address https://github.com/sourcegraph/sourcegraph/issues/28845.

Merge request reports

Loading