From 399d966ee044d6a2aaf4fd63d87cb1a7406ad36e Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 6 Mar 2018 10:07:45 +0200 Subject: [PATCH] Merge Topbar location search with existing search filters If the user is on the SearchPage, submitting a new location should also keep the existing query params and merge the new location params with those. --- src/components/Topbar/Topbar.js | 4 +++- src/containers/SearchPage/SearchPage.js | 2 +- .../SearchPage/__snapshots__/SearchPage.test.js.snap | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Topbar/Topbar.js b/src/components/Topbar/Topbar.js index 6103aef5..c5da15bb 100644 --- a/src/components/Topbar/Topbar.js +++ b/src/components/Topbar/Topbar.js @@ -222,10 +222,12 @@ class TopbarComponent extends Component { } handleSubmit(values) { + const { currentPage, location } = this.props; const { search, selectedPlace } = values.location; const { history } = this.props; const { origin, bounds, country } = selectedPlace; - const searchParams = { address: search, origin, bounds, country }; + const restParams = currentPage === 'SearchPage' ? parse(location.search) : {}; + const searchParams = { ...restParams, address: search, origin, bounds, country }; history.push(createResourceLocatorString('SearchPage', routeConfiguration(), {}, searchParams)); } diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 862d2cbe..018e3c78 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -394,7 +394,7 @@ export class SearchPageComponent extends Component { mainEntity: [schemaMainEntity], }} > - +
- +