mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
fix(tabs): update tab closing logic to handle dormant tabs
- Modified the `closeTab` function in the `useTabs` hook to reactivate dormant tabs when closed. - Ensured that dormant tabs are marked as active and their state is updated upon reactivation, improving tab management and user experience. These changes enhance the functionality of tab closing, providing a smoother interaction with dormant tabs.
This commit is contained in:
parent
bcbd5ed717
commit
eec9048c11
@ -197,13 +197,19 @@ export function useTabs() {
|
||||
|
||||
const closeTab = useCallback(
|
||||
(id: string) => {
|
||||
const newTabs = tabs.filter((t) => t.id !== id)
|
||||
let newTabs = tabs.filter((t) => t.id !== id)
|
||||
let newActiveId = activeTabId
|
||||
|
||||
if (activeTabId === id) {
|
||||
const index = tabs.findIndex((t) => t.id === id)
|
||||
const nextTab = newTabs[index - 1] || newTabs[index]
|
||||
newActiveId = nextTab ? nextTab.id : ''
|
||||
|
||||
if (nextTab?.isDormant) {
|
||||
newTabs = newTabs.map((t) =>
|
||||
t.id === nextTab.id ? { ...t, isDormant: false, lastAccessTime: Date.now() } : t
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
setTabsState({ tabs: newTabs, activeTabId: newActiveId })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user