From b4b9c50208174a75d36c5528cdc41c0b0efdee1d Mon Sep 17 00:00:00 2001 From: Kevin Bulteel Date: Sat, 9 Mar 2024 15:18:59 +0100 Subject: [PATCH] fix: ahref routing --- packages/@hec.js/ui/lib/src/routing.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/@hec.js/ui/lib/src/routing.js b/packages/@hec.js/ui/lib/src/routing.js index 735e0f0..98fe60a 100644 --- a/packages/@hec.js/ui/lib/src/routing.js +++ b/packages/@hec.js/ui/lib/src/routing.js @@ -93,12 +93,12 @@ export const updateRouting = () => { firstMatch = true; meta.content = route.pattern.pathname; - updateGroup(route.group); + return route.group.length ? updateGroup(route.group) : true; } } } - updateGroup(routes); + return updateGroup(routes); } const onNavigate = (event) => { @@ -107,8 +107,11 @@ const onNavigate = (event) => { if (href && url.hostname == location.hostname) { if (routes.some(e => e.pattern.test(href))) { - history.pushState(null, null, href); - event.preventDefault(); + _pushState.call(window.history, null, null, href); + + if (updateRouting()) { + event.preventDefault(); + } } }