Project

General

Profile

Actions

Defect #43801

closed

Copy button appears only on the last pre when multiple pre blocks exist

Defect #43801: Copy button appears only on the last pre when multiple pre blocks exist

Added by Mizuki ISHIKAWA 9 months ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Category:
UI
Target version:
-
Resolution:
Fixed
Affected version:

Description

When a page contains multiple pre blocks, the copy button is displayed only on the last pre block.
Expected behavior: A copy button should be shown for each pre block.

This issue occurs after applying r24360 from issue #43643.


Related issues 1 (0 open — 1 closed)

Related to Redmine - Patch #42737: Replacing html-pipeline with Loofah for HTML FilteringClosedMarius BĂLTEANUActions

Updated by Mizuki ISHIKAWA 9 months ago Actions #1

I think the following changes will resolve the issue.

diff --git a/lib/redmine/wiki_formatting/copypre_scrubber.rb b/lib/redmine/wiki_formatting/copypre_scrubber.rb
index 2afd02823..0157f9921 100644
--- a/lib/redmine/wiki_formatting/copypre_scrubber.rb
+++ b/lib/redmine/wiki_formatting/copypre_scrubber.rb
@@ -27,6 +27,7 @@ module Redmine
         button_copy = ApplicationController.helpers.l(:button_copy)
         html = '<a class="copy-pre-content-link icon-only" title="' + button_copy + '" data-action="clipboard#copyPre">' + icon + '</a>'
         @button ||= Nokogiri::HTML5.fragment(html).children.first
+        @button.deep_dup
       end
     end
   end

Updated by Go MAEDA 9 months ago Actions #2

  • Assignee set to Marius BĂLTEANU

Marius, could you handle this?

Updated by Marius BĂLTEANU 9 months ago Actions #3

Yes, I will do it these days.

Updated by Marius BĂLTEANU 9 months ago Actions #4

  • Related to Patch #42737: Replacing html-pipeline with Loofah for HTML Filtering added

Updated by Marius BĂLTEANU 9 months ago Actions #5

  • Status changed from New to Resolved
  • Resolution set to Fixed

Fixed by removing the cached instance variable. In this way, if the user changes his language, the copy button will properly show the updated translation.

Updated by Marius BĂLTEANU 9 months ago Actions #6

  • Status changed from Resolved to Closed

Added a test.

Actions

Also available in: PDF Atom