fix: put plugin logic inside setInputProps onChange
This commit is contained in:
parent
756a505590
commit
2140a63add
|
@ -117,18 +117,9 @@ export function useUppy({
|
||||||
uppyInstance.current?.addFiles(files)
|
uppyInstance.current?.addFiles(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We clear the input after a file is selected, because otherwise
|
uppy.iteratePlugins((plugin) => {
|
||||||
// change event is not fired in Chrome and Safari when a file
|
uppy.removePlugin(plugin);
|
||||||
// with the same name is selected.
|
});
|
||||||
// ___Why not use value="" on <input/> instead?
|
|
||||||
// Because if we use that method of clearing the input,
|
|
||||||
// Chrome will not trigger change if we drop the same file twice (Issue #768).
|
|
||||||
// @ts-expect-error TS freaks out, but this is fine
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
event.target.value = null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
uppy.use(UppyFileUpload, { sdk: sdk as Sdk })
|
uppy.use(UppyFileUpload, { sdk: sdk as Sdk })
|
||||||
|
|
||||||
|
@ -144,6 +135,17 @@ export function useUppy({
|
||||||
uppy.use(Tus, { endpoint: endpoint, limit: 6 })
|
uppy.use(Tus, { endpoint: endpoint, limit: 6 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We clear the input after a file is selected, because otherwise
|
||||||
|
// change event is not fired in Chrome and Safari when a file
|
||||||
|
// with the same name is selected.
|
||||||
|
// ___Why not use value="" on <input/> instead?
|
||||||
|
// Because if we use that method of clearing the input,
|
||||||
|
// Chrome will not trigger change if we drop the same file twice (Issue #768).
|
||||||
|
// @ts-expect-error TS freaks out, but this is fine
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
event.target.value = null
|
||||||
|
}
|
||||||
|
})
|
||||||
uppy.on("complete", (result) => {
|
uppy.on("complete", (result) => {
|
||||||
if (result.failed.length === 0) {
|
if (result.failed.length === 0) {
|
||||||
console.log("Upload successful üòÄ")
|
console.log("Upload successful üòÄ")
|
||||||
|
|
Loading…
Reference in New Issue