From: Kohei Yoshino Date: Sun, 8 Mar 2020 19:39:53 +0000 (-0400) Subject: Bug 1620236 - Comments on submitted bugs are re-populated if user chooses to show... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e4ba8b23bc5d3dc64f3dcdbee70e02eb405f536;p=thirdparty%2Fbugzilla.git Bug 1620236 - Comments on submitted bugs are re-populated if user chooses to show next bug in my list after changing a bug --- 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 %]