From 33463c4cc2b377973b43eba55d56752bb2ae4ccc Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Wed, 11 Dec 2024 12:15:32 +0100 Subject: [PATCH] fix: appended path on fast navigate (#20673) (#20675) When navigating in quick succession check that path starts with / as else react wll append to current url. Fixes #20671 Co-authored-by: caalador --- .../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 687a1598886..eb72d07c389 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 @@ -367,7 +367,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;