react-instantsearch-router-nextjs 7.5.0 → 7.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,11 @@ function createInstantSearchRouterNext(options) {
33
33
  }
34
34
  }, routerOptions));
35
35
  }
36
+
37
+ /**
38
+ * Marker to skip `routeChangeComplete` event when the push comes from the router itself.
39
+ */
40
+ var lastPushFromThis = false;
36
41
  var router = (0, _history.default)(_objectSpread({
37
42
  start: function start(onUpdate) {
38
43
  var _singletonRouter$rout;
@@ -43,9 +48,10 @@ function createInstantSearchRouterNext(options) {
43
48
  handler = function handler() {
44
49
  // Without this check, we would trigger an unnecessary search when navigating
45
50
  // to a page without InstantSearch
46
- if (singletonRouter.pathname === initialPathname) {
51
+ if (singletonRouter.pathname === initialPathname && !lastPushFromThis) {
47
52
  onUpdate();
48
53
  }
54
+ lastPushFromThis = false;
49
55
  };
50
56
  singletonRouter.events.on('routeChangeComplete', handler);
51
57
  if ((_singletonRouter$rout = singletonRouter.router) !== null && _singletonRouter$rout !== void 0 && _singletonRouter$rout._bps) {
@@ -93,6 +99,7 @@ function createInstantSearchRouterNext(options) {
93
99
  singletonRouter.push(url, undefined, {
94
100
  shallow: true
95
101
  });
102
+ lastPushFromThis = true;
96
103
  }
97
104
  }, routerOptions));
98
105
  router._isNextRouter = true;
package/dist/es/index.js CHANGED
@@ -26,6 +26,11 @@ export function createInstantSearchRouterNext(options) {
26
26
  }
27
27
  }, routerOptions));
28
28
  }
29
+
30
+ /**
31
+ * Marker to skip `routeChangeComplete` event when the push comes from the router itself.
32
+ */
33
+ var lastPushFromThis = false;
29
34
  var router = history(_objectSpread({
30
35
  start: function start(onUpdate) {
31
36
  var _singletonRouter$rout;
@@ -36,9 +41,10 @@ export function createInstantSearchRouterNext(options) {
36
41
  handler = function handler() {
37
42
  // Without this check, we would trigger an unnecessary search when navigating
38
43
  // to a page without InstantSearch
39
- if (singletonRouter.pathname === initialPathname) {
44
+ if (singletonRouter.pathname === initialPathname && !lastPushFromThis) {
40
45
  onUpdate();
41
46
  }
47
+ lastPushFromThis = false;
42
48
  };
43
49
  singletonRouter.events.on('routeChangeComplete', handler);
44
50
  if ((_singletonRouter$rout = singletonRouter.router) !== null && _singletonRouter$rout !== void 0 && _singletonRouter$rout._bps) {
@@ -86,6 +92,7 @@ export function createInstantSearchRouterNext(options) {
86
92
  singletonRouter.push(url, undefined, {
87
93
  shallow: true
88
94
  });
95
+ lastPushFromThis = true;
89
96
  }
90
97
  }, routerOptions));
91
98
  router._isNextRouter = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-instantsearch-router-nextjs",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "React InstantSearch Router for Next.js",
5
5
  "source": "src/index.ts",
6
6
  "types": "dist/es/index.d.ts",
@@ -49,8 +49,8 @@
49
49
  "test:e2e:saucelabs": "start-server-and-test test:start-server 3000 'wdio run ./wdio.saucelabs.conf.cjs'"
50
50
  },
51
51
  "dependencies": {
52
- "instantsearch.js": "4.63.0",
53
- "react-instantsearch-core": "7.5.0"
52
+ "instantsearch.js": "4.64.0",
53
+ "react-instantsearch-core": "7.5.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/jasmine": "3.3.16",
@@ -67,5 +67,5 @@
67
67
  "peerDependencies": {
68
68
  "next": ">= 9 && < 15"
69
69
  },
70
- "gitHead": "b90c55a93cd6fe56128d9d6c746c153dbb3c3649"
70
+ "gitHead": "d1e415e522b9d43162a6ca3a16c6c450dfa8b457"
71
71
  }