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

Number Fields use String value storage; allow step="any" attribute #30

Merged
merged 2 commits into from
Jul 11, 2019

Conversation

mattdb
Copy link
Contributor

@mattdb mattdb commented Jul 11, 2019

Note: this PR requires bumping the package version, I believe it can go with the rest of the 8.0 changes currently in master. Should it miss 8.0, a new version bump would need to be added.

As discussed in #25, storing number fields' values as Maybe Floats caused issues when entering decimal values. This updates number fields' value storage to use String.

Also related to decimals in number fields, the HTML spec allows the step attribute to be set to "any" to allow arbitrary precision. (If the step attribute is not present on the number input, the default is a step value of 1 (Integers only)). Making use of the "any" value is of interest to our app.

Accordingly, I changed the step item in NumberField.Attributes from number to Maybe number-- The idea being specifying Nothing means any step value is allowed.

Step could probably be more elegantly and clearly modeled with a custom type — do we want to introduce that level of complexity? Something like:

type NumberStep number
    = AnyStep
    | Step number

I feel like using Maybe is consistent with the rest of the Api design, but let me know if you prefer the custom type, I'm happy to add it if you'd prefer.

Step would probably be more elegantly modeled with a custom type — do we want to introduce that level of complexity?
@mattdb mattdb marked this pull request as ready for review July 11, 2019 15:49
Copy link
Owner

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

This is great! Thank you!

I think a step of Nothing being translated to any makes sense. In the end, any means no step whatsoever.

Also, thank you for updating the changelog. I will release 8.0 soon!

@hecrj hecrj merged commit 98e7f54 into hecrj:master Jul 11, 2019
@hecrj hecrj added this to the 8.0.0 milestone Jul 11, 2019
@hecrj hecrj added bug Something isn't working enhancement New feature or request labels Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants