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

Global EventListener not removed when component is unmounted #139

Open
rangermeier opened this issue Apr 16, 2021 · 0 comments
Open

Global EventListener not removed when component is unmounted #139

rangermeier opened this issue Apr 16, 2021 · 0 comments

Comments

@rangermeier
Copy link

Hi, thanks for the great component!

I just noted that the component registers an EventListener on document in the mounted hook. To prevent memory leaks, it should be removed via the beforeDestroy hook when the component is unmounted.

E.g.:

{
    mounted () {
        document.addEventListener('click', this.handleClickOutside);
    },
    beforeDestroy () {
        document.removeEventListener('click', this.handleClickOutside);
    },
    methods: {
        handleClickOutside(e) => {
            if (e.target !== this.$refs['taginput']) {
                this.clearSearchResults();
            }
        }
    }
}
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

1 participant