From a1332c3249ff09710965e8cc0538b2358df82683 Mon Sep 17 00:00:00 2001 From: KJ Shanks Date: Thu, 13 Jun 2024 18:07:49 -0400 Subject: [PATCH] Fix empty search in new search flow --- .../search-bar/ConnectedSearchBar.jsx | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx index 7478d2e5a8a..3fc658dd717 100644 --- a/packages/web/src/components/search-bar/ConnectedSearchBar.jsx +++ b/packages/web/src/components/search-bar/ConnectedSearchBar.jsx @@ -88,24 +88,23 @@ class ConnectedSearchBar extends Component { this.props.history.location.search ) - let newPath = pathname if (value) { - if (this.props.isSearchV2Enabled) { - const searchMatch = matchPath( - getPathname(this.props.history.location), - { - path: SEARCH_PAGE - } - ) + locationSearchParams.set('query', value) + } else { + locationSearchParams.delete('query') + } - if (searchMatch) { - newPath = generatePath(SEARCH_PAGE, { - ...searchMatch.params - }) - } - } + let newPath = pathname + if (this.props.isSearchV2Enabled) { + const searchMatch = matchPath(getPathname(this.props.history.location), { + path: SEARCH_PAGE + }) - locationSearchParams.set('query', value) + if (searchMatch) { + newPath = generatePath(SEARCH_PAGE, { + ...searchMatch.params + }) + } } if (value.startsWith('#')) {