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

[Bug]: [NumberInput] Can't enter negative numbers #15985

Closed
2 tasks done
nmgokhale opened this issue Mar 16, 2024 · 3 comments · Fixed by #16100
Closed
2 tasks done

[Bug]: [NumberInput] Can't enter negative numbers #15985

nmgokhale opened this issue Mar 16, 2024 · 3 comments · Fixed by #16100

Comments

@nmgokhale
Copy link

Package

@carbon/react

Browser

Chrome

Package version

1.53.0

React version

18.2.0

Description

I can't type negative numbers (eg. -1) in the NumberInput field. Also when I want to remove all digits, number input is set to 0. Even after setting allowEmpty.

Following screen recording from v10 (https://v10.carbondesignsystem.com/components/number-input/code/#live-demo) no longer works in v11 -

Screen.Recording.2024-03-16.at.3.44.20.PM.mov

Reproduction/example

https://react.carbondesignsystem.com/?path=/story/components-numberinput--playground

Steps to reproduce

Please see description

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

@afkoziol
Copy link

I was just looking into an e2e test failure of ours and it was a result of not being able to empty the input to enter a new number. The zero gets in the way, probably not desirable UX. I believe this was introduced with #15739

Thanks

@ecrvich
Copy link

ecrvich commented Mar 20, 2024

I discovered myself today that allowEmpty has no effect. Maybe consider only zero-filling if the input is empty after focus is lost? Kind of annoying to do it while the user is still typing, and leading zeros suggest octal format to plenty of folks. FWIW in form use, that leading zero DOES of course get passed to the back end intact, so how it's interpreted depends on how the string is converted to a number on that end.

@hollyos
Copy link
Contributor

hollyos commented Apr 1, 2024

@nmgokhale I tested this in the live demo and Storybook. It works in both instances. This issue was likely due to the min value equaling 0. The input allows for negatives when min is updated to a negative value.

@nmgokhale & @ecrvich The empty input is fixed in my PR (#16100)

@2nikhiltom, here's a heads-up that I put up a PR (#16100) for this issue (since you're self-assigned).

@2nikhiltom 2nikhiltom moved this from ⏱ Backlog to 🚦 In Review in Design System Apr 8, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
…rop (#15985) (#16100)

* fix(NumberInput): allow empty input when allowEmpty = true (#15985)

* fix(NumberInput): add @hollyos to contributors (#15985)

* refactor(NumberInput): storybook example default min value updated

* test(numberinput): update avt test to match default story

---------

Co-authored-by: TJ Egan <[email protected]>
Co-authored-by: Nikhil Tomar <[email protected]>
Co-authored-by: Taylor Jones <[email protected]>
Co-authored-by: Taylor Jones <[email protected]>
@github-project-automation github-project-automation bot moved this from 🚦 In Review to ✅ Done in Design System Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants