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

fix(glow-capture): check parent template ref when unmounting #3

Conversation

antoinezanardi
Copy link
Contributor

First of all, I want to thank you for this really cool plugin, keep the good work ❤️ ! However, I found a little problem using it.

👽 The problem

The plugin works pretty good but it faces an issue when you unmount the <GlowCapture> component. It happened when one of my component using a GlowCapture was unmounted. In my case, my component is rendered with a v-if. I had the following error when the v-if condition of my component is set to false :

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'removeEventListener')

It happens in the GlowCapture component, in the onUnmount hook :

onUnmounted(()=>{
    elementParent.value.removeEventListener("pointermove", move); // <-- elementParent.value is null
    elementParent.value.removeEventListener("pointerleave", leave);
}

💎 The solution

I just added an early return if the elementParent.value is undefined or null. That way, it prevents the error.


I hope you find this fix useful. Let me know if something must be changed in my PR.

@aksharahegde aksharahegde merged commit b7a46fa into aksharahegde:main Mar 10, 2024
@aksharahegde
Copy link
Owner

aksharahegde commented Mar 10, 2024

Thank you @antoinezanardi for noticing the issue and fixing it.
I appreciate your contribution. ❤️
Kindly drop your twitter handle here. I would like to shoutout.

@antoinezanardi
Copy link
Contributor Author

Glad you found this fix useful @aksharahegde 🎉 ! I don't have twitter but you can share my profile or/and the project I've been working on which is using your nuxt-glow project : https://github.com/antoinezanardi/werewolves-assistant-web-next

@antoinezanardi
Copy link
Contributor Author

Oh, and don't forget to publish a new release so I can update the dep in my project 😊

@aksharahegde
Copy link
Owner

Published on npm registry.
Thank you

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

Successfully merging this pull request may close these issues.

None yet

3 participants