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.
This commit is contained in:
Kimmo Puputti 2018-03-06 10:07:45 +02:00
parent 887e031a96
commit 399d966ee0
3 changed files with 7 additions and 3 deletions

View file

@ -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));
}

View file

@ -394,7 +394,7 @@ export class SearchPageComponent extends Component {
mainEntity: [schemaMainEntity],
}}
>
<TopbarContainer className={topbarClasses} />
<TopbarContainer className={topbarClasses} currentPage="SearchPage" />
<div className={css.container}>
<div className={css.searchResultContainer}>
<SearchFilters

View file

@ -17,7 +17,9 @@ exports[`SearchPageComponent matches snapshot 1`] = `
scrollingDisabled={false}
title="SearchPage.schemaTitle"
>
<withRouter(Connect(TopbarContainerComponent)) />
<withRouter(Connect(TopbarContainerComponent))
currentPage="SearchPage"
/>
<div>
<div>
<withRouter(InjectIntl(SearchFiltersComponent))