Multiple dropzones on a page
Igor-Golovtsov opened this issue ยท 9 comments
Hello.
When using two or more drop zone components on the same page, a bug occurs. When you click on the first component, the file selection window opens, after selecting the file, the file selection window of the second component immediately opens. When closing the second window, both components break without an error, they just don't work. A unique ID or ref does not correct the situation.
Do you have any suggestions on how to fix this?
Thank you and I apologize for my English.
I'll check on the weekend ^^
in the DropZone.Vue component we should create a parameter for the ref or maybe we should create a random ref for each instance.
What should be better in your opinion?
It seems to me that the best choice is an optional parameter.
When i use dropzoneRef, i have error
Uncaught (in promise) TypeError: Cannot read property 'classList' of undefined
at eval (dropzone-vue.common.js?cd1f:6)
at Array.forEach (<anonymous>)
at initHiddenFileInput (dropzone-vue.common.js?cd1f:6)
at eval (dropzone-vue.common.js?cd1f:6)
at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:6990)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?5c40:6999)
at Array.hook.__weh.hook.__weh (runtime-core.esm-bundler.js?5c40:2270)
at flushPostFlushCbs (runtime-core.esm-bundler.js?5c40:7191)
at flushJobs (runtime-core.esm-bundler.js?5c40:7228)
but, without dropzoneRef everything is fine
It's right the component should use the new ref in order to find some internal element. I'll try to fix it soon as possible
use the different class names for each instance. you can use the dropzoneClassName prop for change. It helps me.
Is the issue resolved? I'm facing the same issue. Tried using different class names but didn't helped.
Thanks
This appears to be happening because the clickable event is registered on .dropzone__message
, and when there are multiple elements with the same class, it's re-registering it on the first one.
I've pushed up a PR which instead uses the class/value passed in dropzoneMessageClassName
to register the event. You will need to pass in a custom message class name, i.e. dropzone-message-class-name="dropzone__message--my_custom_class"
, which is unique for each instance. There might be a better way to do it, but this satisfies my use case.
In the meantime, feel free to use npm i @jaseeey/dropzone-vue
until the issue is addressed. I've just done this now, hopefully no issues :)
fixed version 0.1.11