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

Allow unique id for React DragDrop component #5218

Open
2 tasks done
zachwinnie opened this issue Jun 3, 2024 · 1 comment
Open
2 tasks done

Allow unique id for React DragDrop component #5218

zachwinnie opened this issue Jun 3, 2024 · 1 comment
Assignees
Labels

Comments

@zachwinnie
Copy link

zachwinnie commented Jun 3, 2024

Initial checklist

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

Link to runnable example

No response

Steps to reproduce

The React DragDrop allows consumers to pass in an id prop, but it doesn't actually resolve to the Uppy plugin id. The plugins id is always react:DragDrop. This also prevents consumers from having more than one instance of DragDrop on screen at once.

import { DragDrop } from '@uppy/react';
<DragDrop
  id="my-unique-id" // doesn't work and is always `react:DragDrop`
  uppy={uppy}
/>

This should be a very straightforward fix in packages/@uppy/react/src/DragDrop.ts (I'd push a branch and open a PR but I don't have permission to push code to this repo):

installPlugin(): void {
  const { uppy, locale, inputName, width, height, note, id } = this.props
  const options = {
    id: id || 'react:DragDrop', // this is the fix
    locale,
    inputName,
    width,
    height,
    note,
    target: this.container,
  }

  uppy.use(DragDropPlugin, options)

  this.plugin = uppy.getPlugin(options.id)!
}

Expected behavior

Providing a unique id for React DragDrop component should render unique plugin id. This will allow for multiple versions of DragDrop to be render on screen at once.

Actual behavior

The plugins id is always react:DragDrop even when a unique string for id prop as described above.

@zachwinnie zachwinnie added the Bug label Jun 3, 2024
@Murderlon
Copy link
Member

I will take a look and also remove the react: prefix, it's only confusing imho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants