Mark
Mark

Reputation: 466

What is the best way to handle spurious drag/drop events during development?

Forgive the oddball question, but I am having an issue with drag/drop events during electron development.

The issue is this:

I hope this is explaining the problem adequately. There is no code involved in this question, just an environmental setup query - I'd ideally like for the application to only have to handle a single drop event each time I 'respawn' during development.

I don't foresee this as being a production issue, but more a development annoyance.

Upvotes: 0

Views: 46

Answers (1)

Thomas
Thomas

Reputation: 7078

I had a similar issue with keydown events which got duplicated during server mode. I solved this with lifecycle hooks:

Vue 2:

mounted() {
    window.addEventListener('keydown', this.onKeyDown);
},
destroyed() { // or maybe beforeDestroy
    window.removeEventListener('keydown', this.onKeyDown);
}

Vue 3 Composition API:

onMounted((): void => {
    window.addEventListener('keydown', onKeyDown);
});
onBeforeUnmount((): void => {
    window.removeEventListener('keydown', onKeyDown);
});

Maybe this applies to your code as well.

Upvotes: 1

Related Questions