Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@uppy/angular does not seem to be picking up changes to [props] attribute for <uppy-dashboard> #5071

Closed
2 tasks done
bdirito opened this issue Apr 10, 2024 · 1 comment · Fixed by #5082
Closed
2 tasks done
Labels

Comments

@bdirito
Copy link
Contributor

bdirito commented Apr 10, 2024

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

https://stackblitz.com/edit/uppy-demo-ajunvm?file=src%2Fapp.component.ts

Steps to reproduce

On the linked demo the uppy dashboard loads with the the option {disabled: true}. If you click the button labeled 'Update the props object passed to uppy-dashboard' angular will update the object being passed to the '[props]' attribute of <uppy-dashboard> This can be seen by 'Props are' text being updated.

Expected behavior

I would expect updates to the [props] attribute of <uppy-dashboard> to be picked up; and for the new value of {disabled: false} to enable interactivity.

Actual behavior

The dashboard remains disabled.

As a workaround I've found that you can set the options directly as via an uppy.setOptions(); call. Passing in what are fundamentally dashboard options to the uppy object itself is very much Illegal according to the documented apis & types. But it does seem to work. This behavior can be seen by first pressing the 'Update the props object passed to uppy-dashboard' button to update the properties and then pressing the 'Directly apply the props via object call' to preform the workaround.

@bdirito bdirito added the Bug label Apr 10, 2024
@bdirito bdirito changed the title @uppy/angular does not seem to be picking up changes to [props] attribute @uppy/angular does not seem to be picking up changes to [props] attribute for <uppy-dashboard> Apr 10, 2024
@aduh95
Copy link
Contributor

aduh95 commented Apr 12, 2024

I would expect updates to the [props] attribute of <uppy-dashboard> to be picked up; and for the new value of {disabled: false} to enable interactivity.

Interestingly, the value is picked up, you can see if you replace the uppy.setOptions with

uppy.getPlugin('angular:Dashboard')!.setOptions(this.uppyOptions());

then the second button doesn't have any more effect than changing the props. However, if we change it to

(uppy.getPlugin('angular:Dashboard') as any).setPluginState({})

Then it works the same as calling uppy.setOptions(). The bug seems to be that Dashboard (and maybe other UI components are also affected) does not re-render when setOptions is called. On the Uppy class, some custom logic was added to take this behavior into account, maybe we should do the same on Dashboard/UIPlugin:

// Note: this is not the preact `setState`, it's an internal function that has the same name.
this.setState(undefined) // so that UI re-renders with new options

//cc @Murderlon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants