-
Notifications
You must be signed in to change notification settings - Fork 377
chore(Number Input): Convert examples to TypeScript #7980
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
chore(Number Input): Convert examples to TypeScript #7980
Conversation
|
Preview: https://patternfly-react-pr-7980.surge.sh A11y report: https://patternfly-react-pr-7980-a11y.surge.sh |
e47dc9b to
f7e384b
Compare
nicolethoen
left a comment
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.
Could you update the file names of the examples to be NumberInput<ExampleName>.tsx?
packages/react-core/src/components/NumberInput/examples/NumberCustomStep.tsx
Outdated
Show resolved
Hide resolved
|
|
||
| export const UnitNumberInput: React.FunctionComponent = () => { | ||
| const [value1, setValue1] = React.useState(90); | ||
| const [value2, setValue2] = React.useState(Number((1.0).toFixed(2))); |
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.
So I'm noticing here that the 1.00 which was part of the original example is now displaying at 1 - and it's actually because by passing (1.0).toFixed(2) to a Number constructor, you are casting a string to a number and losing the extra trailing two zeros.
This is necessary because the type of the value prop on NumberInput is number | null, so it cannot accept a string 1.00 value. It's possible we could update the number input value to accept strings and cast them to numbers internally. Not sure what side effects there'd be for that.
@tlabaj I'm not sure if you have thoughts about how we can handle this. I can open a follow up issue if we want - only if we are happy to the update to the example
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.
I think getting rid of Number here will fix the issue.
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.
But the value prop has the type Number, and type of (1.0).toFixed(2) is string
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.
I would say it is fine as is then. The previous implementation was technically incorrect since it had value2: (1.0).toFixed(2)
f7e384b to
24a4df0
Compare
|
@nicolethoen thanks for the kind feedback. This really helps my learning journey :) Once you decide about the issue with |
tlabaj
left a comment
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.
LGTM
|
Your changes have been released in:
Thanks for your contribution! 🎉 |
What: Closes #7672
Convert Number Input examples to TypeScript.
Additional issues: