Skip to content

Commit

Permalink
fix(navbar): reset url state when navigating to other tools (#5171)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge authored Nov 10, 2023
1 parent 94fef50 commit 3204916
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ export const ToolLink = forwardRef(function ToolLink(
) {
const {name, ...rest} = props
const state = useRouterState(
useCallback((routerState) => ({...routerState, tool: name, [name]: undefined}), [name]),
useCallback(
() => ({
tool: name,
// make sure to clear tool state when navigating to another tool
[name]: undefined,
}),
[name],
),
)

return <StateLink state={state} {...rest} ref={ref} />
Expand Down

2 comments on commit 3204916

@vercel
Copy link

@vercel vercel bot commented on 3204916 Nov 10, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio.sanity.build
performance-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 3204916 Nov 10, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

Please sign in to comment.