From d17f1696006560324e0494be8385e69f0402bc75 Mon Sep 17 00:00:00 2001 From: caalador Date: Wed, 11 Dec 2024 12:53:54 +0200 Subject: [PATCH] fix: appended path on fast navigate (#20673) When navigating in quick succession check that path starts with / as else react wll append to current url. Fixes #20671 --- .../main/resources/com/vaadin/flow/server/frontend/Flow.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flow-server/src/main/resources/com/vaadin/flow/server/frontend/Flow.tsx b/flow-server/src/main/resources/com/vaadin/flow/server/frontend/Flow.tsx index 683fcbe69ac..ebcf9e252ff 100644 --- a/flow-server/src/main/resources/com/vaadin/flow/server/frontend/Flow.tsx +++ b/flow-server/src/main/resources/com/vaadin/flow/server/frontend/Flow.tsx @@ -366,7 +366,10 @@ function Flow() { // Blocker is handled and the new navigation // gets queued to be executed after the current handling ends. const {pathname, state} = blocker.location; - queuedNavigate(pathname.substring(basename.length), true, { state: state, replace: true }); + // Clear base name to not get /baseName/basename/path + const pathNoBase = pathname.substring(basename.length); + // path should always start with / else react-router will append to current url + queuedNavigate(pathNoBase.startsWith('/') ? pathNoBase : '/'+pathNoBase, true, { state: state, replace: true }); return; } blockerHandled.current = true;