-
Notifications
You must be signed in to change notification settings - Fork 122
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
Remove decimals from age input box #962
Conversation
I'm going to hold off on reviewing this until reviewing #975, as merging this may create merge conflicts, since the prod repo now contains a different input component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your changes on this. I get where you're coming from on this, but it looks like isInteger
changes whenever the user changes the input to a floating-point value, making the age box merely display a float rounded to two variables. The critical issue here, though, is that age
's value_type
in the metadata is described as float
', not int
for some reason. I'm going to open an issue, since it'd be ideal to actually apply universal rules for all int
types instead of trying to determine if something's a float or int on the front end.
There is an issue open for that: PolicyEngine/policyengine-us#3357. However, I think that age is not an int, because there are policies in the back end that require age to be float. I have mentioned one age variable of this type in #962: ccdf_age_group. |
This PR fixes #962 in the following sense: the default value, if integral, will not contain decimals. This PR also addresses another issue: the user can now freely type |
You're right, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perhaps the best workaround to our own back-end limitations, and I do appreciate the additional effort to remove decimal processing that could confuse users. Thanks @abhcs.
Fix #928 by removing trailing zeros if the value is integral.
The change also allows the user to type a value with up to
16
fractional digits and truncates the value only on blur (16
is chosen arbitrarily, of course). This is the more natural behavior because the inability to see the third fractional digit while it changes the second visible fractional digit is confusing. The simple ant-designInputNumber
component withprecision = 2
also allows the user to enter many fractional digits and truncates the value on blur.🤖[deprecated] Generated by Copilot at 0f0d7a9
Summary
🐛🎨🚸
Fixed a formatting bug and improved user typing for float variables in the
VariableEditor
component. Modified the formatter function insrc/pages/household/input/VariableEditor.jsx
.Walkthrough
VariableEditor
component, which allows users to edit the values of policy parameters and household characteristics in thehousehold
page.