From 9e85271fa162fea5f512dfb2bd7f8ef47b5f1c4f Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Fri, 26 May 2023 20:39:47 +0400 Subject: [PATCH] [UBER-179] Fix issue draft cleanup after switching a project (#3258) Signed-off-by: Sergei Ogorelkov --- .../src/components/CreateIssue.svelte | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index 3069f7be93..a64b1b9a89 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -99,9 +99,10 @@ const client = getClient() const hierarchy = client.getHierarchy() const parentQuery = createQuery() - let _space = space + let _space = draft?.space ?? space let object = draft ?? getDefaultObject(id) + let isAssigneeTouched = false function objectChange (object: IssueDraft, empty: any) { if (shouldSaveDraft) { @@ -188,7 +189,7 @@ component, milestone, priority, - space + space: _space } $: if (object.space !== _space) { @@ -278,6 +279,7 @@ } $: spaceQuery.query(tracker.class.Project, { _id: _space }, (res) => { + resetDefaultAssigneeId() currentProject = res.shift() }) @@ -287,8 +289,14 @@ } } + function resetDefaultAssigneeId () { + if (!isAssigneeTouched && !!object.assignee && object.assignee === currentProject?.defaultAssignee) { + object = { ...object, assignee: assignee ?? null } + } + } + function updateAssigneeId (object: IssueDraft, currentProject: Project | undefined) { - if (object.assignee == null && currentProject !== undefined) { + if (!isAssigneeTouched && object.assignee == null && currentProject !== undefined) { if (currentProject.defaultAssignee !== undefined) { object.assignee = currentProject.defaultAssignee } else { @@ -405,6 +413,7 @@ draftController.remove() resetObject() descriptionBox?.removeDraft(false) + isAssigneeTouched = false } async function setParentIssue () { @@ -658,6 +667,7 @@ width={'min-content'} short on:change={({ detail }) => { + isAssigneeTouched = true object.assignee = detail manager.setFocusPos(5) }}