prateekbh / preact-material-components

preact wrapper for "Material Components for the web"
https://material.preactjs.com
MIT License
554 stars 81 forks source link

Switch not responding to props change #1189

Closed eligao closed 5 years ago

eligao commented 5 years ago

When the props (selected, disabled) changes after a Switch component is initiated , it does not change its shape accordingly, thus I cannot create a controlled Switch. The props only affects the initial render of a Switch. A quick example to reproduce the bug: https://codesandbox.io/s/jvkx6zoj75

This might be caused by the upstream as stated here: https://github.com/material-components/material-components-web/tree/master/packages/mdc-switch#initially-disabled-switch Maybe we should use MDCSwitchFoundation.setDisabled and MDCSwitchFoundation.setChecked?

prateekbh commented 5 years ago

Thanks for the repro.. will look into it

eligao commented 5 years ago

I've already created a PR addressing this #1190

cromefire commented 5 years ago

@prateekbh the pr is ready to be merged

prateekbh commented 5 years ago

taking a look now