🪟 🐛 Remount connector form on type switch #19511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This fixes an issue that (timing based) the OAuth button sometims would not render and instead it would render out the raw fields. This time (yeah I know we "fixed" this already two weeks ago) it happened way less reliable.
How
Thanks to the refactorings we've done to the ConnectorForm, we no longer track the actual connector type as part of Formik. The
ConnectorForm
component itself though would still stay the same whenever you switch the connector type (because that's how React works), and just Formik inside that component would reinitialize.This still kept a lot of state inside the
ConnectorForm
component around while changing the connector type. None of that state should actually be kept around when changing connector types. So we added akey
to theConnectorForm
where we render it, that depends on the connector type, which causes React to fully unmount that component and mount a new instance of that component whenever the connector type changes. That way we can be sure no state is kept when switching connector types.With that change we could no longer get into the state where OAuth fields where rendered out raw... and we REALLY tried.
Bonus
Also makes sure the examples in the connector form are always strings, since atm if a connector has an example of
false
it would just not render out, because React doesn't renderfalse
. Making sure this will now be"false"
.