mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-21 09:18:45 +00:00
dashboard: Remove file-added and complete event handlers on uninstall.
This commit is contained in:
parent
18abb9ea71
commit
ecd7b64f3d
1 changed files with 21 additions and 14 deletions
|
|
@ -155,7 +155,9 @@ module.exports = class Dashboard extends Plugin {
|
|||
this.maintainFocus = this.maintainFocus.bind(this)
|
||||
|
||||
this.initEvents = this.initEvents.bind(this)
|
||||
this.onKeydown = this.onKeydown.bind(this)
|
||||
this.handleKeyDown = this.handleKeyDown.bind(this)
|
||||
this.handleFileAdded = this.handleFileAdded.bind(this)
|
||||
this.handleComplete = this.handleComplete.bind(this)
|
||||
this.handleClickOutside = this.handleClickOutside.bind(this)
|
||||
this.toggleFileCard = this.toggleFileCard.bind(this)
|
||||
this.toggleAddFilesPanel = this.toggleAddFilesPanel.bind(this)
|
||||
|
|
@ -317,7 +319,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
}
|
||||
|
||||
// handle ESC and TAB keys in modal dialog
|
||||
document.addEventListener('keydown', this.onKeydown)
|
||||
document.addEventListener('keydown', this.handleKeyDown)
|
||||
|
||||
// this.rerender(this.uppy.getState())
|
||||
this.setFocusToBrowse()
|
||||
|
|
@ -351,7 +353,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
}
|
||||
|
||||
// handle ESC and TAB keys in modal dialog
|
||||
document.removeEventListener('keydown', this.onKeydown)
|
||||
document.removeEventListener('keydown', this.handleKeyDown)
|
||||
|
||||
this.savedActiveElement.focus()
|
||||
|
||||
|
|
@ -370,7 +372,7 @@ module.exports = class Dashboard extends Plugin {
|
|||
return !this.getPluginState().isHidden || false
|
||||
}
|
||||
|
||||
onKeydown (event) {
|
||||
handleKeyDown (event) {
|
||||
// close modal on esc key press
|
||||
if (event.keyCode === ESC_KEY) this.requestCloseModal(event)
|
||||
// maintainFocus on tab key press
|
||||
|
|
@ -457,15 +459,19 @@ module.exports = class Dashboard extends Plugin {
|
|||
this.ro.observe(this.el.querySelector('.uppy-Dashboard-inner'))
|
||||
|
||||
this.uppy.on('plugin-remove', this.removeTarget)
|
||||
this.uppy.on('file-added', (ev) => {
|
||||
this.toggleAddFilesPanel(false)
|
||||
})
|
||||
this.uppy.on('complete', ({ failed, uploadID }) => {
|
||||
if (this.opts.closeAfterFinish && failed.length === 0) {
|
||||
// All uploads are done
|
||||
this.requestCloseModal()
|
||||
}
|
||||
})
|
||||
this.uppy.on('file-added', this.handleFileAdded)
|
||||
this.uppy.on('complete', this.handleComplete)
|
||||
}
|
||||
|
||||
handleFileAdded () {
|
||||
this.toggleAddFilesPanel(false)
|
||||
}
|
||||
|
||||
handleComplete ({ failed, uploadID }) {
|
||||
if (this.opts.closeAfterFinish && failed.length === 0) {
|
||||
// All uploads are done
|
||||
this.requestCloseModal()
|
||||
}
|
||||
}
|
||||
|
||||
removeEvents () {
|
||||
|
|
@ -480,7 +486,8 @@ module.exports = class Dashboard extends Plugin {
|
|||
// window.removeEventListener('resize', this.throttledUpdateDashboardElWidth)
|
||||
window.removeEventListener('popstate', this.handlePopState, false)
|
||||
this.uppy.off('plugin-remove', this.removeTarget)
|
||||
this.uppy.off('file-added', (ev) => this.toggleAddFilesPanel(false))
|
||||
this.uppy.off('file-added', this.handleFileAdded)
|
||||
this.uppy.off('complete', this.handleComplete)
|
||||
}
|
||||
|
||||
toggleFileCard (fileId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue