-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Improve number fields behavior when formatted with a unit #379
Improve number fields behavior when formatted with a unit #379
Conversation
✅ Deploy Preview for kobalte ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Sorry, just noticed the lint issues. Hopefully all addressed, though I couldn't figure out how to run the reporter locally to test (pnpx biome ci didn't report the found issues) |
You can run Edit: Looks good! I need to finish another task then I'll have a look at merging this! |
Thanks for the clarification! Not sure how I missed it first time around. EDIT: Just noticed the failing tests -- I'm really not sure what happened there. It looks like all the NumberField related tests passed: https://github.com/kobaltedev/kobalte/actions/runs/8548307913/job/23525538904?pr=379#step:7:120 but several for TextField failed: https://github.com/kobaltedev/kobalte/actions/runs/8548307913/job/23525538904?pr=379#step:7:148 Is there anything you can think of here that might have led to that? |
Following up to see if there's anything else I can do to help get this across the line. |
Looks like after a re-run everything's green. Any remaining work for me here? |
Hey all good! Almost done with #381 then I'll be able to merge. |
Thanks for the PR! I'll try to replace |
Awesome news, and congrats on the refactor! If there's anything I can help with feel free to @ ping, Kobalte's been a huge help to me! :) |
The new
NumberField
component is awesome, but while using it withstyle: unit
format options specified, I realized it's behavior diverges pretty significantly from the lovely behavior in in the react spectrum component it's based on. This PR brings it closer into line, though it's still not quite perfect.To see the issue:
Expected behavior: The NumberField should normalize the user's input into a valid format
Actual behavior: The displayed value is polluted until submission, at which point it'll do it's best to parse what's there and renormalize.
This PR confirms that the user's changes are still parsable before committing them, without getting in the way of deleting the contents of the field entirely. It generally makes the unit behave like ineditable text.
Note that this may be able to completely replace the
allowedInput
regex prop (and related machinery) which doesn't have an analog in the react-spectrum NumberField, but I didn't want to make that assumption without checking in first.