From bc4d8126f16ac31bd5e5c1c50f652b6bb9486aa0 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Thu, 24 Mar 2022 20:31:26 +0530 Subject: [PATCH] fix: tab deleting side effect --- .../hoppscotch-app/components/collections/ChooseType.vue | 9 +++------ packages/hoppscotch-app/components/collections/index.vue | 3 +++ packages/hoppscotch-app/components/smart/Tabs.vue | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/hoppscotch-app/components/collections/ChooseType.vue b/packages/hoppscotch-app/components/collections/ChooseType.vue index ab8fcc48..fffc68ae 100644 --- a/packages/hoppscotch-app/components/collections/ChooseType.vue +++ b/packages/hoppscotch-app/components/collections/ChooseType.vue @@ -115,10 +115,7 @@ const updateSelectedTeam = (team: TeamData | undefined) => { emit("update-selected-team", team) } -watch( - () => selectedCollectionTab.value, - (newValue: string) => { - updateCollectionsType(newValue) - } -) +watch(selectedCollectionTab, (newValue: string) => { + updateCollectionsType(newValue) +}) diff --git a/packages/hoppscotch-app/components/collections/index.vue b/packages/hoppscotch-app/components/collections/index.vue index 5afb4a17..9b2df6d2 100644 --- a/packages/hoppscotch-app/components/collections/index.vue +++ b/packages/hoppscotch-app/components/collections/index.vue @@ -337,6 +337,9 @@ export default defineComponent({ "collectionsType.selectedTeam"(value) { if (value?.id) this.teamCollectionAdapter.changeTeamID(value.id) }, + currentUser(newValue) { + if (!newValue) this.updateCollectionType("my-collections") + }, }, mounted() { this.subscribeTo(this.teamCollectionAdapter.collections$, (colls) => { diff --git a/packages/hoppscotch-app/components/smart/Tabs.vue b/packages/hoppscotch-app/components/smart/Tabs.vue index 74044f41..f6a8a5fd 100644 --- a/packages/hoppscotch-app/components/smart/Tabs.vue +++ b/packages/hoppscotch-app/components/smart/Tabs.vue @@ -129,6 +129,10 @@ const removeTabEntry = (tabID: string) => { } tabEntries.value.splice(index, 1) + + // If we tried to remove the active tabEntries, switch to first tab entry + if (props.value === tabID) + if (tabEntries.value.length > 0) selectTab(tabEntries.value[0][0]) } provide("tabs-system", {