Closed artknight closed 1 year ago
When the copy-to-clipboard button is inside an element that that has an onclick event, the onclick event is getting triggered.
copy-to-clipboard
Desired behavior: the text gets copied to the clipboard without triggering the underlying event.
Corrective action
e.preventDefault(); // <=== ADDED BY ME e.stopImmediatePropagation(); // < === ADDED BY ME
Affected method ( lines 301 - 331 )
}, { key: "onClick", value: function onClick(e) { e.preventDefault(); // <=== ADDED BY ME e.stopImmediatePropagation(); // < === ADDED BY ME var trigger = e.delegateTarget || e.currentTarget; var action = this.action(trigger) || 'copy'; var text = actions_default({ action: action, container: this.container, target: this.target(trigger), text: this.text(trigger) }); // Fires an event based on the copy operation result. this.emit(text ? 'success' : 'error', { action: action, text: text, trigger: trigger, clearSelection: function clearSelection() { if (trigger) { trigger.focus(); } window.getSelection().removeAllRanges(); } }); } /** * Default `action` lookup function. * @param {Element} trigger */ }, {
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
🐛 Bug Report
When the
copy-to-clipboard
button is inside an element that that has an onclick event, the onclick event is getting triggered.Desired behavior: the text gets copied to the clipboard without triggering the underlying event.
Corrective action
Affected method ( lines 301 - 331 )