]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1620236 - Comments on submitted bugs are re-populated if user chooses to show...
authorKohei Yoshino <kohei.yoshino@gmail.com>
Sun, 8 Mar 2020 19:39:53 +0000 (15:39 -0400)
committerGitHub <noreply@github.com>
Sun, 8 Mar 2020 19:39:53 +0000 (15:39 -0400)
extensions/BugModal/web/bug_modal.js
template/en/default/bug/process/results.html.tmpl

index d34760cd974a8da535bbd1e3b110a82f0a9df4f5..107b6af007fbebc00678e263813ea469004eb058 100644 (file)
@@ -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() {
index 759605f6b408288893634ee60fadda5b56f0d15f..17d21393a1cc29200a9c7d8887336a7014427597 100644 (file)
@@ -49,7 +49,7 @@
 
 [% Hook.process('title') %]
 
-<dl class="change-summary bug" data-type="[% type FILTER html %]">
+<dl class="change-summary bug" data-type="[% type FILTER html %]" data-id="[% id FILTER html %]">
   <dt>[% title.$type %]</dt>
   <dd>
     [% PROCESS "bug/process/bugmail.html.tmpl" mailing_bugid = id %]