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
Checkboxes don't toggle #35
Comments
@STRML - thanks for the detailed report. Looks like something changed between 0.14.0-rc1 and 0.14.0-rc2. @alitaheri any thoughts? |
We're planning to make all our components controllable with stateful wrappers to help with forms. There are indeed many problems regarding how state is handled. and we should not handle state at all! It's the user's concern how the data flows through their application. we shouldn't make assumptions! @STRML Whenever you get the time please open an issue in material-ui repository too. We should track these bugs Thanks 😁... oh sorry I meant ( ^_^ ) |
😀 |
Great, thanks! |
No worries. Can you test against master, and if all looks good for you, I'll push a new release. |
👍 Works here. |
It appears the internal
switched
property (on MUI Checkbox) is no longer being toggled properly when wrapped in a<FormsyCheckbox>
.It appears that:
<EnhancedSwitch>
's_handleChange()
.this.props.onParentShouldUpdate()
, which is implemented by<Checkbox>
and callsthis.setState({switched: true})
.<EnhancedSwitch>
also callsthis.props.onSwitch()
, which is implemented by<Checkbox>
.<Checkbox>
calls its ownonCheck
which is set by Formsy-MUI.setValue()
, which fires anothersetState()
.<FormsyCheckbox>
to rerender, which fires<Checkbox>
's componentWillReceiveProps.<Checkbox>
's componentWillReceiveProps calls its ownsetState()
, which looks at the value ofthis.state.switched
and overwrites it. But it hasn't changed yet, the transition is still pending, so it is always set tofalse
.Not sure what the fix is here.
<EnhancedSwitch>
should probably be passing a callback toonParentShouldUpdate()
that it can send tosetState()
, to ensure the state transition flushes before any other handlers fire.The text was updated successfully, but these errors were encountered: