Skip to content

Commit cd3804c

Browse files
committed
Fire the hashchange event if the navigation is changing only location.hash
1 parent 5395ddf commit cd3804c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/qwik-city/src/runtime/src/qwik-city-component.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ export const QwikCityProvider = component$<QwikCityProps>((props) => {
253253
if (isBrowser) {
254254
// Use `location.href` because the lastDest signal is only updated on page navigates.
255255
if (type === 'link' && dest.href !== location.href) {
256-
history.pushState(null, '', dest);
256+
const withoutHash = dest.href.split('#')[0];
257+
if (location.href.startsWith(withoutHash + '#')) {
258+
location.hash = dest.hash;
259+
} else {
260+
history.pushState(null, '', dest);
261+
}
257262
}
258263

259264
// Always scroll on same-page popstates, #hash clicks, or links.

0 commit comments

Comments
 (0)