uppy icon indicating copy to clipboard operation
uppy copied to clipboard

`file-editor:cancel` event is incorrectly implemented

Open Murderlon opened this issue 1 year ago • 0 comments

Initial checklist

  • [X] I understand this is a bug report and questions should be posted in the Community Forum
  • [X] I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

  • Use @uppy/dashboard with @uppy-image-editor
  • Add .on('file-editor:cancel', () => console.log('foo'))
  • Add a local file
  • Click "Edit file X"
  • Click "Edit file"
  • Click "Cancel"

Expected behavior

file-editor:cancel should have fired.

Actual behavior

Nothing happens.

In https://github.com/transloadit/uppy/pull/3875 the file-editor:cancel event was added. However, it fires when you cancel the meta data editing screen instead of the cancel inside the image editor. This is incorrect.

The correct solution isn't easy unfortunately. Cancel is called here:

https://github.com/transloadit/uppy/blob/c658883cbfe1ef570dab38518bd87f0686dd9125/packages/%40uppy/dashboard/src/components/EditorPanel.jsx#L20-L26

hideAllPanels has no knowledge plugins so we can't fire it there, then every "Cancel" would have that event, instead of just the cancel for the image editor. Currently, this event only fires when the plugin is uninstalled during editing. But this is a strange edge case and I would say the value of file-editor:cancel would mostly come from the cancel button.

Murderlon avatar Aug 24 '22 15:08 Murderlon