From 54fd900de98ad547a625b9c4d000dfa5293bb8d7 Mon Sep 17 00:00:00 2001 From: Dan Matthews Date: Wed, 15 Jan 2025 10:06:10 +0000 Subject: [PATCH] Add optional chaining to prevent history issue. We've hit a strange bug where this particular line causes an issue after using `Inertia::location()` - it tries to read the `page` parameter of `window.history.state` which i'm assuming is reset during an Inertia::location() call? Adding the optional chaining modifier (as already exists in another reference to this variable further up the page) would fix this for us. --- packages/core/src/history.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/history.ts b/packages/core/src/history.ts index 03846d2ad..01ac4e54d 100644 --- a/packages/core/src/history.ts +++ b/packages/core/src/history.ts @@ -101,7 +101,7 @@ class History { return Promise.resolve().then(() => { this.doReplaceState( { - page: window.history.state.page, + page: window.history.state?.page, scrollRegions, }, this.current.url!, @@ -115,7 +115,7 @@ class History { return Promise.resolve().then(() => { this.doReplaceState( { - page: window.history.state.page, + page: window.history.state?.page, documentScrollPosition: scrollRegion, }, this.current.url!,