diff --git a/packages/app/src/context/layout.tsx b/packages/app/src/context/layout.tsx index d30fd11cf..28fe628a8 100644 --- a/packages/app/src/context/layout.tsx +++ b/packages/app/src/context/layout.tsx @@ -682,12 +682,15 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext( if (!current) return const all = current.all.filter((x) => x !== tab) + if (current.active !== tab) { + setStore("sessionTabs", session, "all", all) + return + } + + const index = current.all.findIndex((f) => f === tab) + const next = current.all[index - 1] ?? current.all[index + 1] ?? all[0] batch(() => { setStore("sessionTabs", session, "all", all) - if (current.active !== tab) return - - const index = current.all.findIndex((f) => f === tab) - const next = all[index - 1] ?? all[0] setStore("sessionTabs", session, "active", next) }) },