Parcourir la source

Make file-editor:cancel event fire when the Image Editor “cancel” button is pressed (#4684)

* Make file-editor:cancel event fire when the Image Editor “cancel” button is pressed

* Don't emit `file-editor:cancel` when canceling in the meta editor
Artur Paikin il y a 1 an
Parent
commit
0acb99e371

+ 6 - 1
packages/@uppy/dashboard/src/components/EditorPanel.jsx

@@ -4,6 +4,11 @@ import classNames from 'classnames'
 function EditorPanel (props) {
   const file = props.files[props.fileCardFor]
 
+  const handleCancel = () => {
+    props.uppy.emit('file-editor:cancel', file)
+    props.hideAllPanels()
+  }
+
   return (
     <div
       className={classNames('uppy-DashboardContent-panel', props.className)}
@@ -20,7 +25,7 @@ function EditorPanel (props) {
         <button
           className="uppy-DashboardContent-back"
           type="button"
-          onClick={props.hideAllPanels}
+          onClick={handleCancel}
         >
           {props.i18n('cancel')}
         </button>

+ 0 - 2
packages/@uppy/dashboard/src/components/FileCard/index.jsx

@@ -9,7 +9,6 @@ import RenderMetaFields from './RenderMetaFields.jsx'
 
 export default function FileCard (props) {
   const {
-    uppy,
     files,
     fileCardFor,
     toggleFileCard,
@@ -53,7 +52,6 @@ export default function FileCard (props) {
   }
 
   const handleCancel = () => {
-    uppy.emit('file-editor:cancel', file)
     toggleFileCard(false)
   }