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 Steppers dont pass value to onChange #14807

Closed
2 tasks done
chrisdudley opened this issue Oct 7, 2023 · 2 comments
Closed
2 tasks done

[Bug]: NumberInput Steppers dont pass value to onChange #14807

chrisdudley opened this issue Oct 7, 2023 · 2 comments

Comments

@chrisdudley
Copy link

Package

@carbon/react

Browser

Chrome

Package version

1.39.0

React version

18.2.0

Description

NumberInput steppers don't pass the value to the onChange handler.

    <NumberInput
      helperText="Optional helper text"
      id="tj-input"
      invalidText="Number is not valid"
      label="Number input label"
      onChange={(e) => onValueChange(e.target.value)}
    />

The above code works correctly when a value is typed into the field, but if the steppers are used then e.target.value is never set because e.target is the SVG icon.

This used to work in Carbon 10, but we recently upgraded to 11 and so now being affected by this bug.

Reproduction/example

https://codesandbox.io/s/cool-darkness-z6lv6n?file=/index.js

Steps to reproduce

Use the steppers to change the value and then look at the console - if you type in the number field it will correctly tell you the value, if you use the steppers then you just get undefined.

Suggested Severity

None

Application/PAL

IBM API Connect

Code of Conduct

@github-actions github-actions bot added the adopter: strategic-product Work-stream that directly effects the Product-led Growth initiative. label Oct 7, 2023
@tw15egan
Copy link
Collaborator

The onChange also passes along extra data so that the values can be captured properly when the change is fired from the steppers:

Screenshot 2023-10-10 at 1 58 36 PM

Here's an example: https://stackblitz.com/edit/github-vc9epf?file=src%2FApp.jsx

@chrisdudley
Copy link
Author

@tw15egan that works perfectly, thank you so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants