Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: prevent keypress actions in the loading state (#4462)

xLansangb6fba6f50e5e
diff --git a/packages/hoppscotch-common/src/components/collections/Add.vue b/packages/hoppscotch-common/src/components/collections/Add.vue
index 2a39b7d4b..4d2a81d42 100644
--- a/packages/hoppscotch-common/src/components/collections/Add.vue
+++ b/packages/hoppscotch-common/src/components/collections/Add.vue
@@ -69,6 +69,10 @@ watch(
)
const addNewCollection = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (!editingName.value) {
toast.error(t("collection.invalid_name"))
return
diff --git a/packages/hoppscotch-common/src/components/collections/AddFolder.vue b/packages/hoppscotch-common/src/components/collections/AddFolder.vue
index e8f3aaf15..30cec3b09 100644
--- a/packages/hoppscotch-common/src/components/collections/AddFolder.vue
+++ b/packages/hoppscotch-common/src/components/collections/AddFolder.vue
@@ -69,10 +69,15 @@ watch(
)
const addFolder = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (editingName.value.trim() === "") {
toast.error(t("folder.invalid_name"))
return
}
+
emit("add-folder", editingName.value)
}
diff --git a/packages/hoppscotch-common/src/components/collections/AddRequest.vue b/packages/hoppscotch-common/src/components/collections/AddRequest.vue
index d3066b744..26eb32a01 100644
--- a/packages/hoppscotch-common/src/components/collections/AddRequest.vue
+++ b/packages/hoppscotch-common/src/components/collections/AddRequest.vue
@@ -166,10 +166,15 @@ watch(
)
const addRequest = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (editingName.value.trim() === "") {
toast.error(`${t("error.empty_req_name")}`)
return
}
+
emit("add-request", editingName.value)
}
diff --git a/packages/hoppscotch-common/src/components/collections/Edit.vue b/packages/hoppscotch-common/src/components/collections/Edit.vue
index 2199b639b..7b3a7a771 100644
--- a/packages/hoppscotch-common/src/components/collections/Edit.vue
+++ b/packages/hoppscotch-common/src/components/collections/Edit.vue
@@ -69,6 +69,10 @@ watch(
)
const saveCollection = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (editingName.value.trim() === "") {
toast.error(t("collection.invalid_name"))
return
diff --git a/packages/hoppscotch-common/src/components/collections/EditFolder.vue b/packages/hoppscotch-common/src/components/collections/EditFolder.vue
index 4df949e93..295f7c8e2 100644
--- a/packages/hoppscotch-common/src/components/collections/EditFolder.vue
+++ b/packages/hoppscotch-common/src/components/collections/EditFolder.vue
@@ -69,6 +69,10 @@ watch(
)
const editFolder = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (editingName.value.trim() === "") {
toast.error(t("folder.invalid_name"))
return
diff --git a/packages/hoppscotch-common/src/components/collections/EditRequest.vue b/packages/hoppscotch-common/src/components/collections/EditRequest.vue
index 0bd1f0223..7ab69bf2e 100644
--- a/packages/hoppscotch-common/src/components/collections/EditRequest.vue
+++ b/packages/hoppscotch-common/src/components/collections/EditRequest.vue
@@ -154,6 +154,10 @@ const submittedFeedback = ref(false)
const { submitFeedback, isSubmitFeedbackPending } = useSubmitFeedback()
const editRequest = () => {
+ if (props.loadingState) {
+ return
+ }
+
if (editingName.value.trim() === "") {
toast.error(t("request.invalid_name"))
return
diff --git a/packages/hoppscotch-common/src/components/environments/teams/Details.vue b/packages/hoppscotch-common/src/components/environments/teams/Details.vue
index 3906dced5..ec76c847d 100644
--- a/packages/hoppscotch-common/src/components/environments/teams/Details.vue
+++ b/packages/hoppscotch-common/src/components/environments/teams/Details.vue
@@ -352,6 +352,10 @@ const removeEnvironmentVariable = (id: number) => {
const isLoading = ref(false)
const saveEnvironment = async () => {
+ if (isLoading.value) {
+ return
+ }
+
isLoading.value = true
if (!editingName.value) {
diff --git a/packages/hoppscotch-common/src/components/teams/Add.vue b/packages/hoppscotch-common/src/components/teams/Add.vue
index d557ef8fc..de0203deb 100644
--- a/packages/hoppscotch-common/src/components/teams/Add.vue
+++ b/packages/hoppscotch-common/src/components/teams/Add.vue
@@ -63,6 +63,10 @@ const isLoading = ref(false)
const workspaceService = useService(WorkspaceService)
const addNewTeam = async () => {
+ if (isLoading.value) {
+ return
+ }
+
isLoading.value = true
await pipe(
TeamNameCodec.decode(editingName.value),