From 9e2c8ffa15374cd024574e8a5e95afe4ae3f442d Mon Sep 17 00:00:00 2001 From: enna Date: Wed, 27 May 2020 12:23:21 +0200 Subject: [PATCH 1/2] Handle "container" option of clipboardJS --- addon/components/copy-button.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addon/components/copy-button.js b/addon/components/copy-button.js index 739cde1..886dbf7 100644 --- a/addon/components/copy-button.js +++ b/addon/components/copy-button.js @@ -60,7 +60,7 @@ export default class CopyButtonComponent extends Component { * @returns {Object} newly created ClipboardJS object */ _createClipboard() { - const { clipboardText: text, delegateClickEvent } = this; + const { clipboardText: text, container, delegateClickEvent } = this; const trigger = delegateClickEvent === false ? this._buttonElement @@ -68,6 +68,10 @@ export default class CopyButtonComponent extends Component { return new ClipboardJS(trigger, { text: typeof text === 'function' ? text : undefined, + container: + typeof container === 'string' + ? document.querySelector(container) + : container, }); } From b60c210052f0c59c64ea549f4d599a3f74974c8a Mon Sep 17 00:00:00 2001 From: enna Date: Tue, 2 Jun 2020 15:29:51 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1bdac26..c740c42 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ http://jkusa.github.io/ember-cli-clipboard - `clipboardText` - string value or action that returns a string to be copied - `clipboardTarget` - selector string of element from which to copy text - `clipboardAction` - string value of operation: `copy` or `cut` (default is copy) +- `container` - selector string or element object of containing element. "For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container value". - `delegateClickEvent` - clipboard.js defaults event listeners to the body in order to reduce memory footprint if there are hundreds of event listeners on a page. If you want to scope the event listener to the copy button, set this property to `false` - `buttonType` - string value of the button's [type attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Attributes)