From 4e4ba8b23bc5d3dc64f3dcdbee70e02eb405f536 Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Sun, 8 Mar 2020 15:39:53 -0400 Subject: [PATCH] Bug 1620236 - Comments on submitted bugs are re-populated if user chooses to show next bug in my list after changing a bug --- extensions/BugModal/web/bug_modal.js | 22 ++++++++++++------- .../en/default/bug/process/results.html.tmpl | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index d34760cd9..107b6af00 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -114,14 +114,20 @@ $(function() { localStorage.setItem(key, JSON.stringify(value)); } - function clearSavedBugComment() { - let key = `bug-modal-saved-comment-${BUGZILLA.bug_id}`; - localStorage.removeItem(key); - } - - // Clear saved comment once the bug is successfully updated - if (document.querySelector('.change-summary[data-type="bug"]')) { - clearSavedBugComment(); + /** + * Clear comment cache once the comment field is emptied or the bug is successfully updated. + * @param {Number} [bug_id] Bug ID to be used for the cache key. The updated bug will be different from the current + * bug when the user has changed the “after changing a bug” preference to “show next bug in my list.” Pass a bug ID + * to take such special cases into account. Otherwise the current bug’s comment cache will be removed. + */ + const clearSavedBugComment = (bug_id = BUGZILLA.bug_id) => { + localStorage.removeItem(`bug-modal-saved-comment-${bug_id}`); + }; + + const $change_summary = document.querySelector('.change-summary[data-type="bug"]'); + + if ($change_summary) { + clearSavedBugComment(Number($change_summary.dataset.id)); } function restoreSavedBugComment() { diff --git a/template/en/default/bug/process/results.html.tmpl b/template/en/default/bug/process/results.html.tmpl index 759605f6b..17d21393a 100644 --- a/template/en/default/bug/process/results.html.tmpl +++ b/template/en/default/bug/process/results.html.tmpl @@ -49,7 +49,7 @@ [% Hook.process('title') %] -
+
[% title.$type %]
[% PROCESS "bug/process/bugmail.html.tmpl" mailing_bugid = id %] -- 2.47.3