Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: bounds were overwritten by state. #1320

Merged
merged 2 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2020-XX-XX

- [fix] MainPanel: search filter bug. Address and bounds are handled outside of MainPanel, URL
params should be trusted instead of values stored to state.
[#1320](https://github.com/sharetribe/ftw-daily/pull/1320)
- [fix] small typo. [#1319](https://github.com/sharetribe/ftw-daily/pull/1319)
- [fix] Fix typo (which is copy-pasted in 4 files).
[#1318](https://github.com/sharetribe/ftw-daily/pull/1318)
Expand Down
9 changes: 8 additions & 1 deletion src/containers/SearchPage/MainPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,15 @@ class MainPanel extends Component {

return updatedURLParams => {
const updater = prevState => {
const { address, bounds } = urlQueryParams;
const mergedQueryParams = { ...urlQueryParams, ...prevState.currentQueryParams };
return { currentQueryParams: { ...mergedQueryParams, ...updatedURLParams } };

// Address and bounds are handled outside of MainPanel.
// I.e. TopbarSearchForm && search by moving the map.
// We should always trust urlQueryParams with those.
return {
currentQueryParams: { ...mergedQueryParams, ...updatedURLParams, address, bounds },
};
};

const callback = () => {
Expand Down