|
@@ -7,6 +7,7 @@ const Informer = require('@uppy/informer')
|
|
|
const ThumbnailGenerator = require('@uppy/thumbnail-generator')
|
|
|
const findAllDOMElements = require('@uppy/utils/lib/findAllDOMElements')
|
|
|
const toArray = require('@uppy/utils/lib/toArray')
|
|
|
+const cuid = require('cuid')
|
|
|
|
|
|
const ResizeObserver = require('resize-observer-polyfill').default || require('resize-observer-polyfill')
|
|
|
const { defaultTabIcon } = require('./components/icons')
|
|
@@ -40,7 +41,7 @@ module.exports = class Dashboard extends Plugin {
|
|
|
this.id = this.opts.id || 'Dashboard'
|
|
|
this.title = 'Dashboard'
|
|
|
this.type = 'orchestrator'
|
|
|
- this.modalName = 'uppy-Dashboard'
|
|
|
+ this.modalName = `uppy-Dashboard-${cuid()}`
|
|
|
|
|
|
const defaultLocale = {
|
|
|
strings: {
|
|
@@ -140,7 +141,7 @@ module.exports = class Dashboard extends Plugin {
|
|
|
}
|
|
|
|
|
|
|
|
|
- this.opts = Object.assign({}, defaultOptions, opts)
|
|
|
+ this.opts = { ...defaultOptions, ...opts }
|
|
|
|
|
|
|
|
|
this.translator = new Translator([ defaultLocale, this.uppy.locale, this.opts.locale ])
|
|
@@ -256,7 +257,10 @@ module.exports = class Dashboard extends Plugin {
|
|
|
|
|
|
if (!history.state || !history.state[this.modalName]) {
|
|
|
|
|
|
- history.pushState({ [this.modalName]: true }, '')
|
|
|
+ history.pushState({
|
|
|
+ ...history.state,
|
|
|
+ [this.modalName]: true
|
|
|
+ }, '')
|
|
|
}
|
|
|
|
|
|
|
|
@@ -265,7 +269,7 @@ module.exports = class Dashboard extends Plugin {
|
|
|
|
|
|
handlePopState (event) {
|
|
|
|
|
|
- if (!event.state || !event.state[this.modalName]) {
|
|
|
+ if (this.isModalOpen() && (!event.state || !event.state[this.modalName])) {
|
|
|
this.closeModal({ manualClose: false })
|
|
|
}
|
|
|
|
|
@@ -337,6 +341,12 @@ module.exports = class Dashboard extends Plugin {
|
|
|
manualClose = true
|
|
|
} = opts
|
|
|
|
|
|
+ const { isHidden, isClosing } = this.getPluginState()
|
|
|
+ if (isHidden || isClosing) {
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if (this.opts.disablePageScrollWhenModalOpen) {
|
|
|
document.body.classList.remove('uppy-Dashboard-isFixed')
|
|
|
}
|