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 field] Support decimal values #41

Closed
mj12albert opened this issue Aug 17, 2023 · 7 comments
Closed

[number field] Support decimal values #41

mj12albert opened this issue Aug 17, 2023 · 7 comments
Assignees
Labels
component: number field This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@mj12albert
Copy link
Member

mj12albert commented Aug 17, 2023

  1. This feature request was raised in [base-ui] Create useNumberInput and NumberInput material-ui#36119 (comment). It requires [useNumberInput] Warn when switching between controlled and uncontrolled state material-ui#38514 to be implemented first.

  2. The handling of the step that is not an integer is broken. e.g. open https://mui.com/base-ui/react-number-input/#component

Screen.Recording.2023-10-03.at.01.33.46.mov

Benchmarks

@mj12albert mj12albert self-assigned this Oct 6, 2023
@michaldudak michaldudak transferred this issue from mui/material-ui Feb 27, 2024
@michaldudak michaldudak changed the title [base-ui][useNumberInput] Support decimal values [NumberInput] Support decimal values Feb 27, 2024
@michaldudak michaldudak added component: number field This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature labels Feb 27, 2024
@oliviertassinari oliviertassinari changed the title [NumberInput] Support decimal values [number field] Support decimal values Mar 22, 2024
@AarCon
Copy link

AarCon commented Apr 21, 2024

One way that I found to make this work is implementing the Math.round() in the value prop like this:

<NumberInput
  aria-label="Demo number input"
  placeholder="Type a number…"
  value={Math.round(value * 10) / 10}
  step={0.1}
  onChange={(event, val) => setValue(val)}
/>

It's not the most elegant solution as it adds processing time after the fact but it's one way of forcing it to be a decimal with the correct formatting.

@colmtuite
Copy link
Contributor

Hey @AarCon, we've shipped a new alpha NumberField component which supports decimal values, alongside a few other cool features. Check it out and let us know what you think! https://base-ui.netlify.app/base-ui/react-number-field/

@michaldudak
Copy link
Member

Closing the issue as we support decimal values in the new NumberField.

@github-project-automation github-project-automation bot moved this from In progress to Done in Base UI Alpha Aug 2, 2024
@user2745
Copy link

hey @michaldudak , can you share the release this was published in? I'm looking to add number input to my platform.

@michaldudak
Copy link
Member

We released the NumberField in @base_ui/[email protected]. Note that it's an alpha release and we still may introduce breaking changes.

@lebadapetru
Copy link

Closing the issue as we support decimal values in the new NumberField.

We released the NumberField in @base_ui/[email protected]. Note that it's an alpha release and we still may introduce breaking changes.

Hey @michaldudak , first of thank you for all the work, the base ui helps a lot in my project and you guys have saved me a lot of work.
I was working on implementing the number field and couldn't find the decimal support for it in the "@mui/base": "^5.0.0-beta.63", is it only available in the @base_ui/[email protected] ?

@michaldudak
Copy link
Member

That's right, it's not available in @mui/base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: number field This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
Archived in project
Development

No branches or pull requests

6 participants