Skip to content

Commit

Permalink
Push history when route changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbyul-here committed Sep 28, 2023
1 parent 9a45998 commit 747c059
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ <h1>{{appTitle}}</h1>
}

document.addEventListener('click', function (event) {
if (event.target.tagName == 'A') {
window.location.replace(event.target.href)
}
});
event.preventDefault();
if (event.target.tagName == 'A' && event.target.href) {
window.history.pushState({}, '', window.location.toString());
window.location.replace(event.target.href);
}
});
</script>

<script type='module' src='./scripts/main.tsx'></script>
Expand Down

0 comments on commit 747c059

Please sign in to comment.