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

Use parse instead of format when calculating checked #974

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jharding
Copy link

This may be an incorrect assumption, but it seems like the getter for checked should be using parse, not format when comparing values. In addition to fixing an issue I was experiencing, the TypeScript definitions suggest this should be the intended behavior as well as parse returns FieldValue and state.config is of the type FieldValue.

I added a couple of tests to prevent future regressions – please let me know if there's anything else I should do to get this to a state where you'd be comfortable accepting the patch.

Thanks for the great library!

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9839445:

Sandbox Source
React Final Form - Simple Example Configuration
React Final Form - Synchronous Record Level Validation Configuration
React Final Form - Synchronous Field Level Validation Configuration
final-form/react-final-form Configuration
React Final Form - Subscriptions Example Configuration

@@ -161,14 +161,14 @@ function useField<FormValues: FormValuesShape>(
get checked() {
let value = state.value;

Choose a reason for hiding this comment

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

value should probably be const as you can call parse right here, then you could remove line 164 and change 171 to `return value === _value"

@nkappler
Copy link

I'm not a maintainer, just interested in this PR as I stumbled upon it due to this bug #560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants