Uppy: Order of .use should not influence behavior

Created on 9 Mar 2020  路  2Comments  路  Source: transloadit/uppy

Fiddle here

Bug:
Restrictions are not applied correctly.

Description:
In the fiddle I have two Uppy instances, in both using DragDrop, testing that the order of .use influence behavior when I apply a restriction for Uppy:

  • first instance: Uppy.Core().use(XHRUpload, {...}).use(DragDrop, {...}) - incorrect behavior
  • second instance: Uppy.Core().use(DragDrop, {...}).use(XHRUpload, {...})

at the end I apply the same restriction for both, but in the first instance the restriction is not set even if the console log is what you would expect, when trying to upload a file, no restriction is there.
uppy1.opts.restrictions.allowedFileTypes = ['.jpg', '.xls'];
uppy2.opts.restrictions.allowedFileTypes = ['.jpg', '.xls'];

You can also inspect the elements:

  • first instance:
    image
  • second instance:
    image
Core Question

All 2 comments

Are you updating the options with precisely that line?

uppy.opts.restrictions.allowedFileTypes = [...list]

Manually setting options properties after passing them to Uppy is not supported. You have to use the setOptions() method because Uppy has to do some reinitialization if its settings are changed.

uppy.setOptions({
  restrictions: {
    allowedFileTypes: [...list]
  }
})

https://jsfiddle.net/bst7fah0/1/

Thanks for the answer!

Yes, I was using that line, it was before the setOptions was added :D

Was this page helpful?
0 / 5 - 0 ratings