Kaynağa Gözat

Modal dashboard fix :face_palm:

Renée Kooi 6 yıl önce
ebeveyn
işleme
2e51841ebd

+ 3 - 1
examples/transloadit/index.html

@@ -45,7 +45,9 @@
         <p>
           <label>
             attachments:
-            <span class="dashboard"></span>
+            <span class="dashboard">
+              <input type="file" name="files" multiple>
+            </span>
           </label>
           <div class="progress"></div>
 

+ 1 - 1
examples/transloadit/main.js

@@ -14,7 +14,7 @@ const formUppy = transloadit.form('#test-form', {
     auth: { key: '05a61ed019fe11e783fdbd1f56c73eb0' },
     template_id: 'be001500a56011e889f9cddd88df842c'
   },
-  dashboard: '#test-form .dashboard',
+  modal: true,
   progressBar: '#test-form .progress'
 })
 

+ 4 - 3
packages/@uppy/transloadit-preset/src/form.js

@@ -28,18 +28,19 @@ function form (target, opts) {
   const useDashboard = opts.dashboard || opts.modal
 
   if (useDashboard) {
-    const dashboardTarget = findDOMElement(opts.dashboard)
+    const dashboardTarget = findDOMElement(opts.dashboard) || document.body
     const dashboardId = 'form:Dashboard'
     const dashboardOpts = {
       id: dashboardId,
       target: dashboardTarget
     }
     if (opts.modal) {
-      let trigger = 'input[type="file"]'
+      const trigger = 'input[type="file"]'
       const button = document.createElement('button')
       button.textContent = 'Select files'
+      button.type = 'button'
       const old = findDOMElement(trigger, findDOMElement(target))
-      old.parentNode.replaceChild(old, button)
+      old.parentNode.replaceChild(button, old)
       dashboardOpts.trigger = button
     } else {
       dashboardOpts.inline = true