Commit 966a4c28 authored by Rajat Jain's avatar Rajat Jain

Remove paste event listener on destroy

Prevent event leak from happening when hooked
event is not unhooked on destroy

Changelog: fixed
parent 4a9cf749
......@@ -140,6 +140,9 @@ export default {
this.$el.scrollIntoView();
}
},
beforeDestroy() {
document.removeEventListener('paste', this.onDesignPaste);
},
methods: {
resetFilesToBeSaved() {
this.filesToBeSaved = [];
......
......@@ -630,6 +630,16 @@ describe('Design management index page', () => {
expect(mockMutate).not.toHaveBeenCalled();
});
it('does not upload designs if designs wrapper is destroyed', () => {
findDesignsWrapper().trigger('mouseenter');
wrapper.destroy();
document.dispatchEvent(event);
expect(mockMutate).not.toHaveBeenCalled();
});
describe('when designs wrapper is hovered', () => {
let realDateNow;
const today = () => new Date('2020-12-25');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment