From 799cf4af5a64b45e0fcbae64f278a7efa66ce2fb Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sat, 3 Oct 2026 17:41:35 +0900 Subject: [PATCH 2/2] Show the history tab when the journal linked from an issue attachment is hidden --- .../issue_journal_link_controller.js | 15 +++++++++++++++ app/views/attachments/_links.html.erb | 3 ++- test/system/issues_test.rb | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/javascript/controllers/issue_journal_link_controller.js diff --git a/app/javascript/controllers/issue_journal_link_controller.js b/app/javascript/controllers/issue_journal_link_controller.js new file mode 100644 index 000000000..abaa9fce4 --- /dev/null +++ b/app/javascript/controllers/issue_journal_link_controller.js @@ -0,0 +1,15 @@ +import { Controller } from "@hotwired/stimulus"; + +export default class extends Controller { + // Shows the history tab if the target note is hidden by the selected tab, + // so that the browser can jump to the note + show() { + const note = document.getElementById(this.element.hash.slice(1)); + if (!note || note.getClientRects().length > 0) return; + + const historyTab = document.getElementById("tab-history"); + if (!historyTab) return; + + showIssueHistory("history", historyTab.href); + } +} diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index eb2b9cdfd..3da85ff2b 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -27,7 +27,8 @@ <% anchor = "#note-#{journal.indice}" %> <%= link_to sprite_icon('chevrons-down', anchor), anchor, :title => anchor, - :class => 'icon-only icon-chevrons-down' %> + :class => 'icon-only icon-chevrons-down', + :data => {:controller => 'issue-journal-link', :action => 'issue-journal-link#show'} %> <% end %> <% end %> diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index c0b0d8a49..e902a8df9 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -718,6 +718,23 @@ class IssuesSystemTest < ApplicationSystemTestCase assert page.has_no_css?('#add_notes') end + def test_attachment_note_link_should_show_history_tab_if_note_is_hidden + # Journal 3 added attachment 4 to issue 2. Without notes, it is hidden in the notes tab + Journal.find(3).update_column(:notes, '') + Journal.create!(:journalized => Issue.find(2), :user_id => 2, :notes => 'A note') + + log_user('jsmith', 'jsmith') + visit '/issues/2?tab=notes' + + assert_selector '#tab-notes.selected' + assert_no_selector '#note-1' + + find('div.attachments span.attachment-journal a').click + + assert_selector '#tab-history.selected' + assert_selector '#note-1' + end + def test_preview_custom_field_on_bulk_edit_across_projects field = IssueCustomField.create!( :field_format => 'text', -- 2.55.0