Skip to content

Commit

Permalink
Merge pull request #17134 from storybookjs/fix/16918-mdx-hash-link
Browse files Browse the repository at this point in the history
Router: Fix navigating to hash links
  • Loading branch information
shilman committed Jan 5, 2022
2 parents 6b765b7 + 1ab9ad9 commit 4188513
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/router/src/router.tsx
Expand Up @@ -61,6 +61,10 @@ const useQueryNavigate = () => {
const navigate = useNavigate();

return useCallback((to: string | number, options?: ExpandedNavigateOptions) => {
if (typeof to === 'string' && to.startsWith('#')) {
document.location.hash = to;
return undefined;
}
if (typeof to === 'string') {
const target = options?.plain ? to : `?path=${to}`;
return navigate(target, options);
Expand Down

0 comments on commit 4188513

Please sign in to comment.