fix(core): fix active view undefined (#6131)

close https://github.com/toeverything/AFFiNE/issues/6127, #6132
This commit is contained in:
EYHN
2024-03-15 03:45:40 +00:00
parent 12c04a8575
commit 9ba47f43bb

View File

@@ -98,8 +98,9 @@ export class Workbench {
if (index === -1) return;
const newViews = [...this.views.value];
newViews.splice(index, 1);
if (index !== 0) {
this.active(index - 1);
const activeViewIndex = this.activeViewIndex.value;
if (activeViewIndex !== 0 && activeViewIndex >= index) {
this.active(activeViewIndex - 1);
}
this.views.next(newViews);
}