Skip to content

Commit 0237b94

Browse files
committed
Fix: Set route=closed when sidebar is closed instead of deleting param
1 parent b502737 commit 0237b94

File tree

1 file changed

+4
-10
lines changed
  • packages/playground/website/src/lib/state/url

1 file changed

+4
-10
lines changed

packages/playground/website/src/lib/state/url/router.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export function parseRouteParam(route: string | null): RouteState {
6060

6161
/**
6262
* Build a route parameter string from a RouteState object.
63-
* Returns undefined if the sidebar is closed (default state).
63+
* Returns 'closed' if the sidebar is closed.
6464
*/
65-
export function buildRouteParam(state: RouteState): string | undefined {
65+
export function buildRouteParam(state: RouteState): string {
6666
if (!state.sidebarOpen) {
67-
return undefined;
67+
return 'closed';
6868
}
6969

7070
if (state.section === 'sidebar') {
@@ -89,13 +89,7 @@ export function buildRouteParam(state: RouteState): string | undefined {
8989
export function updateRouteInUrl(state: RouteState): void {
9090
const url = new URL(window.location.href);
9191
const routeValue = buildRouteParam(state);
92-
93-
if (routeValue === undefined) {
94-
url.searchParams.delete('route');
95-
} else {
96-
url.searchParams.set('route', routeValue);
97-
}
98-
92+
url.searchParams.set('route', routeValue);
9993
window.history.replaceState({}, '', url.href);
10094
}
10195

0 commit comments

Comments
 (0)