fixed tabs not closing properly due to id not resetting
mellobacon committed
Aug 24, 2022 at 21:42 UTC
852ec9113379459a85353f1ead296ada47590756
1 file changed
+6
-5
src/components/Content/Editor/Tabs.ts
+6
-5
@@ -69,20 +69,21 @@ function updateEditorVisibility() {
69
}
70
}
71
72
-export function closeTab(id: number) {
73
- tablist[id].editor.$destroy();
74
- tablist = tablist.filter(t => t.id !== id);
72
+export function closeTab(tabid: number) {
73
+ tablist[tabid].editor.$destroy();
74
+ tablist = tablist.filter(t => t.id !== tabid);
75
tabs.set(tablist);
76
for (let _ of tablist) {
77
if (activeid >= tablist.length - 1) {
78
- setActive(id - 1);
78
+ setActive(tabid - 1);
79
}
80
else {
81
- setActive(id + 1);
81
+ setActive(tabid + 1);
82
}
83
}
84
updateEditorVisibility();
85
if (tablist.length === 0) {
86
hidden.set(true);
87
+ id = 0;
88
}
89
}
\ No newline at end of file