From 01282dcc820e61262ca18608b1a07ebd0312630e Mon Sep 17 00:00:00 2001 From: Abdullah Agsar <72465865+AbdullahAgsar@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:56:41 +0300 Subject: [PATCH 1/2] fix chromeIOS and edgeIOS browser back button problems --- packages/core/src/router.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core/src/router.ts b/packages/core/src/router.ts index 2482bea94..93bb3fa12 100644 --- a/packages/core/src/router.ts +++ b/packages/core/src/router.ts @@ -33,6 +33,7 @@ import { hrefToUrl, mergeDataIntoQueryString, urlWithoutHash } from './url' const isServer = typeof window === 'undefined' const isChromeIOS = !isServer && /CriOS/.test(window.navigator.userAgent) +const isEdgeIOS = !isServer && /EdgiOS/.test(window.navigator.userAgent) const cloneSerializable = (obj: T): T => JSON.parse(JSON.stringify(obj)) const nextFrame = (callback: () => void) => { requestAnimationFrame(() => { @@ -495,10 +496,10 @@ export class Router { protected pushState(page: Page): void { this.page = page - if (isChromeIOS) { + if (isChromeIOS || isEdgeIOS) { // Defer history.pushState to the next event loop tick to prevent timing conflicts. // Ensure any previous history.replaceState completes before pushState is executed. - setTimeout(() => window.history.pushState(cloneSerializable(page), '', page.url)) + setTimeout(() => window.history.pushState(cloneSerializable(page), '', page.url), 1) } else { window.history.pushState(cloneSerializable(page), '', page.url) } @@ -506,13 +507,7 @@ export class Router { protected replaceState(page: Page): void { this.page = page - if (isChromeIOS) { - // Defer history.replaceState to the next event loop tick to prevent timing conflicts. - // Ensure any previous history.pushState completes before replaceState is executed. - setTimeout(() => window.history.replaceState(cloneSerializable(page), '', page.url)) - } else { - window.history.replaceState(cloneSerializable(page), '', page.url) - } + window.history.replaceState(cloneSerializable(page), '', page.url) } protected handlePopstateEvent(event: PopStateEvent): void { From 9f04fe6eafd6774353c7038716d72d0ba6746023 Mon Sep 17 00:00:00 2001 From: Abdullah Agsar <72465865+AbdullahAgsar@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:39:59 +0300 Subject: [PATCH 2/2] fix chromeIOS and edgeIOS browsers visit problems --- packages/core/src/router.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/router.ts b/packages/core/src/router.ts index 93bb3fa12..91a4b0ba3 100644 --- a/packages/core/src/router.ts +++ b/packages/core/src/router.ts @@ -271,9 +271,9 @@ export class Router { { method = 'get', data = {}, - replace = false, + replace = true, preserveScroll = false, - preserveState = false, + preserveState = true, only = [], except = [], headers = {},