Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose @uppy/drop-target events #3238

Merged
merged 1 commit into from Oct 5, 2021
Merged

Conversation

Murderlon
Copy link
Member

Supersedes #2973

Alternative approach to make the solution more generic and aligned with previous solutions.

  • Expose events
  • Update types
  • Update docs

The problem @tobiasps posed could now be solved like so (in combination with uppy.setFileMeta)

    .use(DropTarget, {
      // ...
      onDrop: (event) => {
        const { files } = uppyInstance.getState()
        // do something with `event` and `files`
      }),
    })


const files = await getDroppedFiles(event.dataTransfer, { logDropError })
this.addFiles(files)
this.opts.onDrop?.(event)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pass the files here?

Suggested change
this.opts.onDrop?.(event)
this.opts.onDrop?.(event, files)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it but I didn't in the end.

  • It's inconsistent with what we pass in the other events in this plugin, but also with the events in other plugins
  • files here is not the same as this.uppy.getState().files, it is not processed yet so it missing important things like id.
  • the idea of these events is that it can be used for any side effect, so the developer can access whatever they want from the uppy instance should they need it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good point about these being unprocessed files especially.

@Murderlon Murderlon merged commit 0ef42d1 into main Oct 5, 2021
@Murderlon Murderlon deleted the expose-drop-target-events branch October 5, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants