Project

General

Profile

Defect #44317 ยป 0001-Close-the-actions-dropdown-after-copying-a-link.patch

Mizuki ISHIKAWA, 2026-08-04 08:07

View differences:

app/helpers/application_helper.rb
905 905
                    :data => {:action => "click->dropdown#toggle"})
906 906
      items = content_tag('span', content, :class => 'dropdown-items')
907 907
      content = content_tag('span', items, :class => 'dropdown-content hidden', :data => {:dropdown_target => "content"})
908
      content_tag('span', trigger + content, :class => 'dropdown', :data => {:controller => "dropdown"})
908
      content_tag('span', trigger + content, :class => 'dropdown',
909
                  :data => {:controller => "dropdown", :action => "clipboard:copied->dropdown#hide"})
909 910
    end
910 911
  end
911 912

  
app/javascript/controllers/clipboard_controller.js
23 23

  
24 24
  copyText(e) {
25 25
    e.preventDefault();
26
    this.copy(e.currentTarget.dataset.clipboardText);
27

  
28
    const element = e.currentTarget.closest('.drdn.expanded');
29
    if (element !== null) {
30
      element.classList.remove('expanded');
31
    }
26
    this.copy(e.currentTarget.dataset.clipboardText).then(() => {
27
      this.dispatch('copied', { bubbles: true });
28
    });
32 29
  }
33 30

  
34 31
  copy(text) {
app/javascript/controllers/dropdown_controller.js
30 30
      return
31 31
    }
32 32

  
33
    this.hide()
34
  }
35

  
36
  hide() {
33 37
    this.contentTarget.classList.add("hidden")
34 38
    document.removeEventListener("click", this.closeBinding)
35 39
    document.removeEventListener("keydown", this.closeBinding)
test/system/copy_to_clipboard_test.rb
28 28
    first('.contextual span.icon-actions').click
29 29
    find('.contextual .dropdown-items a.icon-copy-link').click
30 30

  
31
    # The dropdown should be closed after copying
32
    assert_no_selector '.contextual .dropdown-items'
33

  
31 34
    # Paste the value copied to the clipboard into the textarea to get and test
32 35
    first('.icon-edit').click
33 36
    find('textarea#issue_notes').send_keys([modifier_key, 'v'])
......
42 45
    first('#note-2 .icon-actions').click
43 46
    first('#note-2 .dropdown-items a.icon-copy-link').click
44 47

  
48
    # The dropdown should be closed after copying
49
    assert_no_selector '#note-2 .dropdown-items'
50

  
45 51
    # Paste the value copied to the clipboard into the textarea to get and test
46 52
    first('.icon-edit').click
47 53
    find('textarea#issue_notes').send_keys([modifier_key, 'v'])
    (1-1/1)