From 8cbc4dca9fdeee7f17cd2796ed5e467cdf5f5af5 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 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;