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

Error in directive clipboard unbind hook #75

Open
whity opened this issue Oct 29, 2019 · 7 comments
Open

Error in directive clipboard unbind hook #75

whity opened this issue Oct 29, 2019 · 7 comments

Comments

@whity
Copy link

whity commented Oct 29, 2019

Hello,

When the component is destroyed, I'm getting the following error:

Error in directive clipboard unbind hook: "TypeError: Cannot read property 'destroy' of undefined"

Thanks.

@cliffrowley
Copy link

FWIW, I have the same issue. It doesn't seem to matter how the button is removed from the DOM (v-if or a route change), it always results in the same error.

@kevin-daniel-hunt
Copy link

+1, I cannot seem to figure out root cause but I am now gutting this package from my project.

@Alex-Golovin
Copy link

Alex-Golovin commented Dec 26, 2019

https://github.com/Inndy/vue-clipboard2#sample-2
use this method - and you will don't have issues

@BryceV
Copy link

BryceV commented May 8, 2020

My team can confirm this is still an issue when the component is destroyed. You get a slightly better log from firefox: 'Error in directive clipboard unbind hook: "TypeError: el._vClipboard is undefined"'. It would be nice to have the directives working but we can confirm sample2 also works.

@Daniel4Digital
Copy link
Contributor

+1 same problem here

@Daniel4Digital
Copy link
Contributor

Daniel4Digital commented May 21, 2021

For what I checked, when the component is loaded with the directives it fires the copy directive.

So instead of firing bind first, it will on some ocasions run unbind first.
When that happen the binding.args have 'copy'.
And it bugs on the last else
else { el._vClipboard.destroy() delete el._vClipboard }

So, to quickly fix this we just need to add
if(!el._vClipboard) return

On the first line of the unbind hook.

PS: This still needs more deep investigation. But at least that would solve this.

best regards

Daniel4Digital added a commit to Daniel4Digital/vue-clipboard2 that referenced this issue May 21, 2021
@GoncaloNevesCorreia
Copy link

When is the PR from above will be merged? It solves for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants