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

fix(toggle-input): allow to pass value prop #1185

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

emmenko
Copy link
Member

@emmenko emmenko commented Nov 18, 2019

TL;DR: in Formik v2 they changed a bit how checkbox and radio inputs deal with values

Formik 2 "fixes" React checkboxes and multi-selects with built-in array binding and boolean behavior

https://github.com/jaredpalmer/formik/releases/tag/v2.0.1

As we are upgrading our apps to formik v2, we started bumping into weird test failures and we narrowed the issue down to checkbox input types. It seems that if no value is provided, the default value is on, as described in the MDN .

You can also see in the following codesandbox how the behavior differs:

image

https://codesandbox.io/s/formik-checkbox-value-i40kv

The fix

It appears that by passing both value and checked to the input, Formik handles the boolean value correctly.

@emmenko emmenko added the 🐛 Type: Bug Something isn't working label Nov 18, 2019
@montezume
Copy link
Contributor

I guess Percy didn't run because the PR wasn't open when the VRTs ran

Copy link
Contributor

@tdeekens tdeekens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaaah. Nice find!

@emmenko emmenko merged commit 9ed5296 into master Nov 19, 2019
@emmenko emmenko deleted the nm-fix-toggle-input-value branch November 19, 2019 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants