Skip to content

Commit

Permalink
Fix router on different pathname and hash triggers hard refresh (#700)
Browse files Browse the repository at this point in the history
Fix router different pathname and hash trigger hard refresh
  • Loading branch information
lukechu10 authored Sep 20, 2024
1 parent b0280cb commit 5763938
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/sycamore-router/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ impl Integration for HistoryIntegration {

let meta_keys_pressed = meta_keys_pressed(ev.unchecked_ref::<KeyboardEvent>());
if !meta_keys_pressed && location.origin() == Ok(origin) {
if location.hash().as_ref() != Ok(&hash) {
// Same origin, same path, different anchor. Use default browser behavior.
} else if location.pathname().as_ref() != Ok(&a_pathname) {
if location.pathname().as_ref() != Ok(&a_pathname) {
// Same origin, different path. Navigate to new page.
ev.prevent_default();
PATHNAME.with(|pathname| {
Expand All @@ -100,6 +98,8 @@ impl Integration for HistoryIntegration {
.unwrap_throw();
window().scroll_to_with_x_and_y(0.0, 0.0);
});
} else if location.hash().as_ref() != Ok(&hash) {
// Same origin, same pathname, different hash. Use default browser behavior.
} else {
// Same page. Do nothing.
ev.prevent_default();
Expand Down

1 comment on commit 5763938

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 5763938 Previous: b0280cb Ratio
reactivity_context_deeply_nested 1691 ns/iter (± 360) 1087 ns/iter (± 225) 1.56

This comment was automatically generated by workflow using github-action-benchmark.

CC: @lukechu10

Please sign in to comment.