diff --git a/packages/instantsearch-core/src/connectors/__tests__/connectGeoSearch.test.ts b/packages/instantsearch-core/src/connectors/__tests__/connectGeoSearch.test.ts index 7f868e26de..6c072d1109 100644 --- a/packages/instantsearch-core/src/connectors/__tests__/connectGeoSearch.test.ts +++ b/packages/instantsearch-core/src/connectors/__tests__/connectGeoSearch.test.ts @@ -176,7 +176,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ toggleRefineOnMapMove: expect.any(Function), isRefineOnMapMove: expect.any(Function), setMapMoveSinceLastRefine: expect.any(Function), - hasMapMoveSinceLastRefine: expect.any(Function), + hasMapMovedSinceLastRefine: expect.any(Function), widgetParams: {}, instantSearchInstance, }, @@ -184,7 +184,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(lastRenderArgs(render).isRefineOnMapMove()).toBe(true); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); widget.render!( @@ -222,7 +222,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(lastRenderArgs(render).isRefineOnMapMove()).toBe(true); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); }); @@ -496,13 +496,13 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(4); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); helper.setQueryParameter('aroundLatLng', '14,16'); @@ -515,7 +515,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(5); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); }); @@ -574,13 +574,13 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(4); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); helper.setQueryParameter('aroundLatLng', '10,12'); @@ -593,7 +593,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(5); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); }); @@ -653,13 +653,13 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(4); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); helper.setQueryParameter('insideBoundingBox', undefined); @@ -672,7 +672,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(5); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); }); @@ -732,13 +732,13 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(4); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); // @ts-ignore @@ -752,7 +752,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(5); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); }); @@ -938,7 +938,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(1); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).not.toHaveBeenCalled(); @@ -953,7 +953,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); expect(helper.state.insideBoundingBox).toEqual('12,10,40,42'); expect(helper.search).toHaveBeenCalledTimes(1); @@ -999,7 +999,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).not.toHaveBeenCalled(); @@ -1014,7 +1014,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); expect(helper.state.insideBoundingBox).toEqual('12,10,40,42'); expect(helper.search).toHaveBeenCalledTimes(1); @@ -1055,7 +1055,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(1); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).not.toHaveBeenCalled(); @@ -1070,7 +1070,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); expect(helper.state.insideBoundingBox).toEqual('12,10,40,42'); expect(helper.search).toHaveBeenCalledTimes(1); @@ -1085,7 +1085,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).toHaveBeenCalledTimes(2); @@ -1131,7 +1131,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).not.toHaveBeenCalled(); @@ -1146,7 +1146,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(true); expect(helper.state.insideBoundingBox).toEqual('12,10,40,42'); expect(helper.search).toHaveBeenCalledTimes(1); @@ -1161,7 +1161,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(4); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); expect(lastRenderArgs(render).isRefinedWithMap()).toBe(false); expect(helper.state.insideBoundingBox).toBe(undefined); expect(helper.search).toHaveBeenCalledTimes(2); @@ -1262,12 +1262,12 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ widget.init!(createInitOptions()); expect(render).toHaveBeenCalledTimes(1); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(1); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); widget.render!( createRenderOptions({ @@ -1280,7 +1280,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(firstRenderArgs(render).setMapMoveSinceLastRefine).toBe( lastRenderArgs(render).setMapMoveSinceLastRefine ); @@ -1318,12 +1318,12 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(firstRenderArgs(render).setMapMoveSinceLastRefine).toBe( lastRenderArgs(render).setMapMoveSinceLastRefine ); @@ -1361,17 +1361,17 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ ); expect(render).toHaveBeenCalledTimes(2); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(false); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(false); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); lastRenderArgs(render).setMapMoveSinceLastRefine(); expect(render).toHaveBeenCalledTimes(3); - expect(lastRenderArgs(render).hasMapMoveSinceLastRefine()).toBe(true); + expect(lastRenderArgs(render).hasMapMovedSinceLastRefine()).toBe(true); expect(firstRenderArgs(render).setMapMoveSinceLastRefine).toBe( lastRenderArgs(render).setMapMoveSinceLastRefine ); @@ -1593,7 +1593,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ currentRefinement: undefined, items: [], clearMapRefinement: expect.any(Function), - hasMapMoveSinceLastRefine: expect.any(Function), + hasMapMovedSinceLastRefine: expect.any(Function), isRefineOnMapMove: expect.any(Function), isRefinedWithMap: expect.any(Function), refine: expect.any(Function), @@ -1630,7 +1630,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ items: [], refine: expect.any(Function), clearMapRefinement: expect.any(Function), - hasMapMoveSinceLastRefine: expect.any(Function), + hasMapMovedSinceLastRefine: expect.any(Function), isRefineOnMapMove: expect.any(Function), isRefinedWithMap: expect.any(Function), setMapMoveSinceLastRefine: expect.any(Function), @@ -1658,7 +1658,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/geo-search/ currentRefinement: undefined, items: [], clearMapRefinement: expect.any(Function), - hasMapMoveSinceLastRefine: expect.any(Function), + hasMapMovedSinceLastRefine: expect.any(Function), isRefineOnMapMove: expect.any(Function), isRefinedWithMap: expect.any(Function), refine: expect.any(Function), diff --git a/packages/instantsearch-core/src/connectors/connectGeoSearch.ts b/packages/instantsearch-core/src/connectors/connectGeoSearch.ts index 3867fe531f..0bf37cbcee 100644 --- a/packages/instantsearch-core/src/connectors/connectGeoSearch.ts +++ b/packages/instantsearch-core/src/connectors/connectGeoSearch.ts @@ -67,7 +67,7 @@ export type GeoSearchRenderState = BaseHit> = { /** * Return true if the map has move since the last refinement. */ - hasMapMoveSinceLastRefine: () => boolean; + hasMapMovedSinceLastRefine: () => boolean; /** * Return true if the current refinement is set with the map bounds. */ @@ -179,8 +179,7 @@ export const connectGeoSearch = function connectGeoSearch< const widgetState = { isRefineOnMapMove: enableRefineOnMapMove, - // @MAJOR hasMapMoveSinceLastRefine -> hasMapMovedSinceLastRefine - hasMapMoveSinceLastRefine: false, + hasMapMovedSinceLastRefine: false, lastRefinePosition: '', lastRefineBoundingBox: '', internalToggleRefineOnMapMove: noop, @@ -207,7 +206,7 @@ export const connectGeoSearch = function connectGeoSearch< ) .search(); - widgetState.hasMapMoveSinceLastRefine = false; + widgetState.hasMapMovedSinceLastRefine = false; widgetState.lastRefineBoundingBox = boundingBox; }; @@ -246,17 +245,17 @@ export const connectGeoSearch = function connectGeoSearch< ) => () => { const shouldTriggerRender = - widgetState.hasMapMoveSinceLastRefine !== true; + widgetState.hasMapMovedSinceLastRefine !== true; - widgetState.hasMapMoveSinceLastRefine = true; + widgetState.hasMapMovedSinceLastRefine = true; if (shouldTriggerRender) { render(renderOptions); } }; - const hasMapMoveSinceLastRefine = () => - widgetState.hasMapMoveSinceLastRefine; + const hasMapMovedSinceLastRefine = () => + widgetState.hasMapMovedSinceLastRefine; let sendEvent: SendEventForHits; @@ -307,7 +306,7 @@ export const connectGeoSearch = function connectGeoSearch< positionChangedSinceLastRefine || boundingBoxChangedSinceLastRefine ) { - widgetState.hasMapMoveSinceLastRefine = false; + widgetState.hasMapMovedSinceLastRefine = false; } widgetState.lastRefinePosition = state.aroundLatLng || ''; @@ -369,7 +368,7 @@ export const connectGeoSearch = function connectGeoSearch< toggleRefineOnMapMove, isRefineOnMapMove, setMapMoveSinceLastRefine, - hasMapMoveSinceLastRefine, + hasMapMovedSinceLastRefine, widgetParams, }; }, diff --git a/packages/instantsearch.js/src/components/GeoSearchControls/GeoSearchControls.tsx b/packages/instantsearch.js/src/components/GeoSearchControls/GeoSearchControls.tsx index 0b8b855ad4..39e49e099a 100644 --- a/packages/instantsearch.js/src/components/GeoSearchControls/GeoSearchControls.tsx +++ b/packages/instantsearch.js/src/components/GeoSearchControls/GeoSearchControls.tsx @@ -22,7 +22,7 @@ type Props = { enableClearMapRefinement: boolean; isRefineOnMapMove: boolean; isRefinedWithMap: boolean; - hasMapMoveSinceLastRefine: boolean; + hasMapMovedSinceLastRefine: boolean; onRefineToggle: (event: Event) => void; onRefineClick: (event: MouseEvent) => void; onClearClick: (event: MouseEvent) => void; @@ -36,7 +36,7 @@ const GeoSearchControls = ({ enableClearMapRefinement, isRefineOnMapMove, isRefinedWithMap, - hasMapMoveSinceLastRefine, + hasMapMovedSinceLastRefine, onRefineToggle, onRefineClick, onClearClick, @@ -47,7 +47,7 @@ const GeoSearchControls = ({
{enableRefineControl && (
- {isRefineOnMapMove || !hasMapMoveSinceLastRefine ? ( + {isRefineOnMapMove || !hasMapMovedSinceLastRefine ? (