properly remove event listener for "focus" and "click" (#6116)

fix https://github.com/transloadit/uppy/issues/6115

---------

Co-authored-by: Mikael Finstad <finstaden@gmail.com>
This commit is contained in:
HKB 2026-01-05 21:49:14 +08:00 committed by GitHub
parent 23186da45d
commit 6975782339
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"@uppy/dashboard": patch
---
Remove event listener for `focus` and `click`, preventing a memory leak.

View file

@ -1028,8 +1028,16 @@ export default class Dashboard<M extends Meta, B extends Body> extends UIPlugin<
this.uppy.off('files-added', this.#generateLargeThumbnailIfSingleFile)
this.uppy.off('file-removed', this.#generateLargeThumbnailIfSingleFile)
document.removeEventListener('focus', this.recordIfFocusedOnUppyRecently)
document.removeEventListener('click', this.recordIfFocusedOnUppyRecently)
document.removeEventListener(
'focus',
this.recordIfFocusedOnUppyRecently,
true,
)
document.removeEventListener(
'click',
this.recordIfFocusedOnUppyRecently,
true,
)
if (this.opts.inline) {
this.el!.removeEventListener('keydown', this.handleKeyDownInInline)