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

onChange fired on mount and unmount #153

Closed
mattcorner opened this issue May 1, 2020 · 3 comments
Closed

onChange fired on mount and unmount #153

mattcorner opened this issue May 1, 2020 · 3 comments

Comments

@mattcorner
Copy link

mattcorner commented May 1, 2020

Bug Report

Describe the bug

As of 3.0.0, the onChange method is fired on dropzone component mount, and also unmount with empty files array. This is undesirable.

Steps to reproduce

Code sandbox demo
Note alert on page load. Note alert on toggling dropzone off so that it is unmounted.

Expected behavior

No callback trigger on mount and unmount. I should only expect an onChange with empty files when a user has removed a file from dropzone.

Versions

  • OS: windows
  • Browser: chrome, edge
  • @material-ui/core version: latest
  • material-ui-dropzone version: 3.0.0

Additional context

@mattcorner
Copy link
Author

Just found the clearOnUnmount option which give me the unmount behaviour I expect. Wonder why I never got unmount callback triggers in 2.x.x. I guess the bug is there rather than 3.0.0

@BGehrels
Copy link

BGehrels commented May 7, 2020

Sadly, this one got closed.

I would definitly love some documentation about this behaviour in the breaking changes section of the release notes.

@panz3r
Copy link
Contributor

panz3r commented May 13, 2020

Hi @mattcorner and @BGehrels ,

Thanks for your feedbacks.

I updated the CHANGELOG to better explain the change about onChange behaviour, also to clarify the main reason behind this change is because of a better handling of the initialFiles prop on mount, the event is also triggered on unmount when the clearOnUnmount prop is set to true.

@panz3r panz3r closed this as completed May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants