From e14cd98903a7d9ec6fbe14a7b9f12d25ad675ffc Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Tue, 21 Aug 2018 11:54:50 +0300 Subject: [PATCH 1/3] Add path check for search page --- src/containers/SearchPage/SearchPage.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 447b2e0a..44a5093a 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -16,7 +16,7 @@ import { sdkBoundsToFixedCoordinates, hasSameSDKBounds, } from '../../util/googleMaps'; -import { createResourceLocatorString } from '../../util/routes'; +import { createResourceLocatorString, pathByRouteName } from '../../util/routes'; import { parse, stringify } from '../../util/urlHelpers'; import { propTypes } from '../../util/types'; import { getListingsById } from '../../ducks/marketplaceData.duck'; @@ -116,10 +116,17 @@ export class SearchPageComponent extends Component { const viewportBoundsChanged = this.viewportBounds && !hasSameSDKBounds(this.viewportBounds, viewportBounds); + const routes = routeConfiguration(); + const searchPagePath = pathByRouteName('SearchPage', routes); + const currentPath = window && window.location && window.location.pathname; + + // When using the ReusableMapContainer onIdle can fire from other pages than SearchPage too + const isSearchPage = currentPath === searchPagePath; + // If mapSearch url param is given (and we have not just opened mobile map modal) // or original location search is rendered once, // we start to react to 'bounds_changed' event by generating new searches - if (viewportBoundsChanged && !this.modalOpenedBoundsChange) { + if (viewportBoundsChanged && !this.modalOpenedBoundsChange && isSearchPage) { const originMaybe = config.sortSearchByDistance ? { origin: googleLatLngToSDKLatLng(viewportGMapBounds.getCenter()) } : {}; @@ -132,9 +139,7 @@ export class SearchPageComponent extends Component { }; this.viewportBounds = viewportBounds; - history.push( - createResourceLocatorString('SearchPage', routeConfiguration(), {}, searchParams) - ); + history.push(createResourceLocatorString('SearchPage', routes, {}, searchParams)); } else { this.viewportBounds = viewportBounds; this.modalOpenedBoundsChange = false; From 80f0112433db3533554a33cdd978a6c6e5c974d4 Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Tue, 21 Aug 2018 12:14:22 +0300 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9669e68..dfb4ec9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ way to update this template, but currently, we follow a pattern: --- ## Upcoming version 2018-08-XX +## v1.4.1 2018-08-21 +* [fix] Fix window resize redirecting to search page with reusable map component + [#905](https://github.com/sharetribe/flex-template-web/pull/905) + ## v1.4.0 2018-08-17 * [change] Put availability calendar behind a feature flag [#902](https://github.com/sharetribe/flex-template-web/pull/902) From 330eb2b8b06e3d76ba25acc8e3a14269ea347bf5 Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Tue, 21 Aug 2018 16:12:55 +0300 Subject: [PATCH 3/3] Improve window availability check --- src/containers/SearchPage/SearchPage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 44a5093a..969015c4 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -118,7 +118,8 @@ export class SearchPageComponent extends Component { const routes = routeConfiguration(); const searchPagePath = pathByRouteName('SearchPage', routes); - const currentPath = window && window.location && window.location.pathname; + const currentPath = + typeof window !== 'undefined' && window.location && window.location.pathname; // When using the ReusableMapContainer onIdle can fire from other pages than SearchPage too const isSearchPage = currentPath === searchPagePath;