From 63eca80ff6fc38ca8999d2edc33c9213ead8672a Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 13 Feb 2024 16:06:45 +0530 Subject: [PATCH] fix: prevent the need for an explicit save while editing request name --- .../src/components/new-collections/rest/index.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-common/src/components/new-collections/rest/index.vue b/packages/hoppscotch-common/src/components/new-collections/rest/index.vue index a17b5bdd6..07bde3f44 100644 --- a/packages/hoppscotch-common/src/components/new-collections/rest/index.vue +++ b/packages/hoppscotch-common/src/components/new-collections/rest/index.vue @@ -711,7 +711,7 @@ const duplicateRequest = async (requestIndexPath: string) => { return } - const requestHandle = cloneDeep(requestHandleResult.right) + const requestHandle = requestHandleResult.right if (requestHandle.value.type === "invalid") { // COLLECTION_INVALIDATED | INVALID_REQUEST_HANDLE @@ -775,6 +775,18 @@ const onEditRequest = async (newRequestName: string) => { return } + const possibleActiveTab = tabs.getTabRefWithSaveContext({ + originLocation: "workspace-user-collection", + requestHandle, + }) + + if (possibleActiveTab) { + possibleActiveTab.value.document.request.name = newRequestName + nextTick(() => { + possibleActiveTab.value.document.isDirty = false + }) + } + displayModalEditRequest(false) toast.success(t("request.renamed")) }