uppy/examples/react/test
Prakash d6b3aa575e
@uppy/components: fix dropzone global id (#5967)
fixes #5946 

Root Cause : 

`createDropzone` used a single global `id` for the file input
(`'uppy-dropzone-file-input'`) Clicking any `<Dropzone />` did
`document.getElementById(<global-id>).click()`, which always targeted
the first input in the DOM, so files were added to the first Uppy
instance.


9bac4c8398/packages/%40uppy/components/src/hooks/dropzone.ts (L73-L77)


**Solutions :**

Simplest solution would have been to just make the input id unique per
Uppy instance using `ctx.uppy.getID()`, and click that specific input.

```typescript

const fileInputId = 'uppy-dropzone-file-input-' + ctx.uppy.getID()

```
  **Caveats**:
  
If users don’t pass a custom id to `new Uppy()`, all instances default
to uppy, so ids still collide across instances.
  Multiple Dropzones under one instance still share the same id.
  

Switched to a ref-based approach so clicks trigger the input directly,
without relying on `document.getElementById` lookups. It still falls
back to a DOM click for backward compatibility.

**StackBlitz Link :** 


https://stackblitz.com/github/qxprakash/uppy/tree/debug_dropzone/examples/react?file=package.json&embed=1&view=editor&showSidebar=1&hideTerminal=1

  


**Update: Went for the ID based solution upon discussion with the team
as it's simpler.**
2025-09-17 10:39:57 +02:00
..
index.test.tsx @uppy/components: fix dropzone global id (#5967) 2025-09-17 10:39:57 +02:00