Defect #44317 ยป 0001-Close-the-actions-dropdown-after-copying-a-link.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
|
:data => {:action => "click->dropdown#toggle"})
|
||
|
items = content_tag('span', content, :class => 'dropdown-items')
|
||
|
content = content_tag('span', items, :class => 'dropdown-content hidden', :data => {:dropdown_target => "content"})
|
||
|
content_tag('span', trigger + content, :class => 'dropdown', :data => {:controller => "dropdown"})
|
||
|
content_tag('span', trigger + content, :class => 'dropdown',
|
||
|
:data => {:controller => "dropdown", :action => "clipboard:copied->dropdown#hide"})
|
||
|
end
|
||
|
end
|
||
| app/javascript/controllers/clipboard_controller.js | ||
|---|---|---|
|
copyText(e) {
|
||
|
e.preventDefault();
|
||
|
this.copy(e.currentTarget.dataset.clipboardText);
|
||
|
const element = e.currentTarget.closest('.drdn.expanded');
|
||
|
if (element !== null) {
|
||
|
element.classList.remove('expanded');
|
||
|
}
|
||
|
this.copy(e.currentTarget.dataset.clipboardText).then(() => {
|
||
|
this.dispatch('copied', { bubbles: true });
|
||
|
});
|
||
|
}
|
||
|
copy(text) {
|
||
| app/javascript/controllers/dropdown_controller.js | ||
|---|---|---|
|
return
|
||
|
}
|
||
|
this.hide()
|
||
|
}
|
||
|
hide() {
|
||
|
this.contentTarget.classList.add("hidden")
|
||
|
document.removeEventListener("click", this.closeBinding)
|
||
|
document.removeEventListener("keydown", this.closeBinding)
|
||
| test/system/copy_to_clipboard_test.rb | ||
|---|---|---|
|
first('.contextual span.icon-actions').click
|
||
|
find('.contextual .dropdown-items a.icon-copy-link').click
|
||
|
# The dropdown should be closed after copying
|
||
|
assert_no_selector '.contextual .dropdown-items'
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||
| ... | ... | |
|
first('#note-2 .icon-actions').click
|
||
|
first('#note-2 .dropdown-items a.icon-copy-link').click
|
||
|
# The dropdown should be closed after copying
|
||
|
assert_no_selector '#note-2 .dropdown-items'
|
||
|
# Paste the value copied to the clipboard into the textarea to get and test
|
||
|
first('.icon-edit').click
|
||
|
find('textarea#issue_notes').send_keys([modifier_key, 'v'])
|
||