Defect #44258
openDeleting an issue journal (note) shifts #note-N anchors of later journals, breaking existing links
Description
Summary¶
Deleting an issue journal (note) renumbers subsequent #note-N anchors, causing existing links to point to the wrong journal.
Steps to reproduce¶
- Create an issue and add 2 notes: "First note" and "Second note" (become #1 and #2).
- Add a 3rd note whose text contains the magic link
#note-2(i.e. it references the "Second note" above). This becomes #3. - With "Edit issue notes" permission, delete note #1 ("First note").
- Reload the issue and check the
#note-2link inside note #3 (now renumbered #2).
Expected result¶
The #note-2 link inside that note still points to "Second note".
Actual result¶
After the renumbering, "Second note" is now #1 and the note containing the link is now #2 . The #note-2 link therefore no longer points to "Second note" — it points to the wrong journal (typically the note containing the link itself, or whichever journal now occupies the #2 position).
Cause¶
Issue#visible_journals_with_index assigns indice dynamically on each request. Since indice is not a stored column (just an attr_accessor), removing a journal row changes the numbering of all later journals on the next render.
Suggested fix¶
Instead of physically deleting the journal row, clear the notes field while keeping the journal row. This preserves the positions of subsequent journals and would likely require only a minimal change to the existing implementation.
Files
