(key: string)
| 130 | }); |
| 131 | |
| 132 | const handleRemoveTab = (key: string) => { |
| 133 | const index = currentTabs.value.findIndex((tab) => tab.key === key); |
| 134 | if (index !== -1) { |
| 135 | currentTabs.value.splice(index, 1); |
| 136 | if (!currentTabs.value.length) { |
| 137 | initDefaultTab(); |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | if (activeTab.value === key) { |
| 142 | // Prefer to switch to the previous tab; if none exists, take the last one |
| 143 | const prevIndex = index > 0 ? index - 1 : currentTabs.value.length - 1; |
| 144 | const nextKey = currentTabs.value[prevIndex]?.key || ""; |
| 145 | activeTab.value = nextKey; |
| 146 | handleChangeTab(nextKey); |
| 147 | } |
| 148 | } |
| 149 | }; |
| 150 | |
| 151 | const onEditTabs = (targetKey: MouseEvent | Key | KeyboardEvent, action: "remove" | "add") => { |
| 152 | if (action === "add") { |
no test coverage detected