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

not work on vuetify dialog #98

Open
jazuly opened this issue Oct 18, 2020 · 8 comments
Open

not work on vuetify dialog #98

jazuly opened this issue Oct 18, 2020 · 8 comments

Comments

@jazuly
Copy link

jazuly commented Oct 18, 2020

im not sure but when i try, it not work on vuetify dialog

@billerby
Copy link

billerby commented Oct 22, 2020

Having the same issue since a while back. Which version of vuetify are you on?

@jazuly
Copy link
Author

jazuly commented Oct 22, 2020

the latest one..

@billerby
Copy link

Well this is fixed in #23 you have to provide a container to make it work on modals.

@orkhan-huseyn
Copy link

Use container option if you're inside Vuetify dialog.

const container = document.querySelector('.v-dialog');

this.$copyText('Your text here', container).then(() => {
     this.snackbar = true;
});

@ziqq
Copy link

ziqq commented Nov 13, 2020

Use this config, it's work.

import VueClipboard from 'vue-clipboard2';
VueClipboard.config.autoSetContainer = true;
Vue.use(VueClipboard);

@alfreema
Copy link

Use container option if you're inside Vuetify dialog.

const container = document.querySelector('.v-dialog');

this.$copyText('Your text here', container).then(() => {
     this.snackbar = true;
});

This worked for me. I am able to use a v-btn inside a v-dialog, and the contents of the clipboard are correct when I paste into a text doc.

Use this config, it's work.

import VueClipboard from 'vue-clipboard2';
VueClipboard.config.autoSetContainer = true;
Vue.use(VueClipboard);

This did not. My v-btn inside the v-dialog fires, the $copyText function fires, but the clipboard does not get updated.

@renatodeleao
Copy link

renatodeleao commented Nov 26, 2020

Looking at the source, the option autoSetContainer is only passed down to vue directive not to the instance prototype function $copyText.

var VueClipboardConfig = {
autoSetContainer: false,
appendToBody: true // This fixes IE, see #50
}
var VueClipboard = {
install: function (Vue) {
Vue.prototype.$clipboardConfig = VueClipboardConfig
Vue.prototype.$copyText = function (text, container) {
return new Promise(function (resolve, reject) {
var fakeElement = document.createElement('button')
var clipboard = new Clipboard(fakeElement, {
text: function () { return text },
action: function () { return 'copy' },
container: typeof container === 'object' ? container : document.body
})

This makes sense, because as an imperative API, it seems to me that you can't infer the container automagically, since the function can be called anywhere — EDIT: that being said, documentation could explicit about it.

So in addendum to @alfreema @orkhan-huseyn answers for the container option:

  • using a vue ref, tike this.$refs.dialog instead of querySelector might be more vue-ish.
  • using this.$el would also be a good candidate for dialogs (if the function is being called within).

Cheers!

@Microhawk
Copy link

If the parent component is a "v-dialog", maybe you can add a tag like "
copySelect=".v-dialog"" in the parent component, then pass the value to the child component. In the child component, code likes the follow.
`let container = document.querySelector(this.copySelect);

this.$copyText('Your text', container).then(() => {
});`

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

7 participants