Просмотр исходного кода

fix(app): session tabs to open the previous opened (#11914)

Rahul A Mistry 2 недель назад
Родитель
Сommit
08671e3155
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      packages/app/src/context/layout.tsx

+ 7 - 4
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)
-            batch(() => {
+            if (current.active !== tab) {
               setStore("sessionTabs", session, "all", all)
-              if (current.active !== tab) return
+              return
+            }
 
-              const index = current.all.findIndex((f) => f === tab)
-              const next = all[index - 1] ?? all[0]
+            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)
               setStore("sessionTabs", session, "active", next)
             })
           },