diff --git a/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts b/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts index ed4d2f3243..36e1e8330e 100644 --- a/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts +++ b/frontend/src/lib/components/sidebar/workspaceSwitchUrl.ts @@ -153,7 +153,7 @@ export async function switchWorkspaceAndPage( ): Promise { const request = ++latestSwitch const missing = !opts?.landOnHome && (await itemPageMissingIn(id)) - // A switch picked while this lookup was in flight wins. + // A switch picked while this lookup (or the navigation home below) was in flight wins. if (request !== latestSwitch) return // Read after the lookup: the user can edit while it is in flight. const unsavedEdits = editorHasUnsavedEdits() @@ -165,6 +165,7 @@ export async function switchWorkspaceAndPage( // applies. On cancel nothing is switched. const from = page.route.id await goto(`/?workspace=${encodeURIComponent(id)}`) + if (request !== latestSwitch) return if (unsavedEdits && page.route.id === from) return switchTo(id) return