Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap modals support #180

Closed
catz opened this issue Apr 17, 2020 · 5 comments
Closed

Bootstrap modals support #180

catz opened this issue Apr 17, 2020 · 5 comments

Comments

@catz
Copy link

catz commented Apr 17, 2020

Please consider adding additional option "container"

From https://clipboardjs.com/ - Advanced Usage section.
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.

Without it component doesn't really copy anything when a button in a popup.

My quick dirty solution

import CopyButtonComponent from 'ember-cli-clipboard/components/copy-button';

export default class CopyButtonWithContainerComponent extends CopyButtonComponent {
  constructor() {
    super(...arguments);
  }

  _createClipboard() {
    const { clipboardText: text, delegateClickEvent } = this;
    const trigger =
      delegateClickEvent === false
        ? this._buttonElement
        : `#${this._buttonElement.id}`;

    return new window.ClipboardJS(trigger, {
      text: typeof text === 'function' ? text : undefined,
      container: this._buttonElement,
    });
  }
}

Thank you

@enna
Copy link
Contributor

enna commented May 26, 2020

Up on it, I also have the issue. ^^ Could it be possible to handle the container option of clipboard.js ? 🙏

@drewdaemon
Copy link

drewdaemon commented Jun 11, 2020

👍 I also have this issue. Thanks for getting that PR taken care of @enna. I'd love to see this support on NPM so we can use it! cc: @jkusa

@Monkeychip
Copy link

👍 I am also having this issue.

@drewdaemon
Copy link

As an interim solution until a release gets cut, I had luck with specifying a commit hash in my package.json file like so:

    "ember-cli-clipboard": "jkusa/ember-cli-clipboard#4af026ceb684dedd297d93b1da731156cf848963",

@jkusa
Copy link
Owner

jkusa commented Jun 25, 2020

Sorry for the delay on this. The container arg is now available in v0.15.0.

@jkusa jkusa closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants