uppy/examples
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
..
angular @uppy/examples: Add new examples (#5942) 2025-09-10 21:46:19 +05:30
aws-companion build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
aws-nodejs Cleanup examples (#5817) 2025-07-10 17:23:58 +02:00
aws-php Cleanup examples (#5817) 2025-07-10 17:23:58 +02:00
cdn Cleanup examples (#5817) 2025-07-10 17:23:58 +02:00
companion fix broken companion example (#5909) 2025-08-18 13:20:59 +02:00
companion-custom-provider build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
companion-digitalocean-spaces build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
nextjs @uppy/examples: Add new examples (#5942) 2025-09-10 21:46:19 +05:30
react @uppy/components: fix dropzone global id (#5967) 2025-09-17 10:39:57 +02:00
reactrouter @uppy/examples: Add new examples (#5942) 2025-09-10 21:46:19 +05:30
sveltekit @uppy/components: fix dropzone global id (#5967) 2025-09-17 10:39:57 +02:00
transloadit build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
vue @uppy/components: fix dropzone global id (#5967) 2025-09-17 10:39:57 +02:00
xhr-bundle build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
xhr-node build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
xhr-php build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00
xhr-python build(deps-dev): bump vite from 7.0.6 to 7.0.7 (#5962) 2025-09-10 15:30:59 +02:00