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

fix(16865): fixes step operations in NumberInput #17048

Merged

Conversation

2nikhiltom
Copy link
Contributor

Closes #16865

This PR fixes the Inconsistent Increment/Decrement behavior in NumberInput Component when value and step are large
The usage of native stepUp() and stepDown() methods is removed
Added test case to verify the behaviour when value and step are large

Changelog

stepUp() and stepDown() methods are removed and Increment/Decrement operations are handled inside our own function

I suspect that native stepUp() and stepDown() methods can be unpredictable with large step values with large values
When the current value (e.g., 1000) matches the step size (e.g., 1000), it seems like browsers treat it as a step boundary. and only increment by just 1 instead of the full step

Testing / Reviewing

Test NumberInput component with below props and any other combination: verify it works as expected

// large values
 <NumberInput
        id="carbon-number"
        min={1}
        max={9900}
        value={1000}
        step={1000}
      />
//allowEmpty and step=0
  <NumberInput
      id="carbon-number"
      min={-100}
      max={100}
      value={''}
      step={0}
      allowEmpty
      
    />
//allowEmpty and step=10
<NumberInput
      id="carbon-number"
      min={-100}
      max={100}
      value={''}
      step={10}
      label="NumberInput label"
      helperText="Optional helper text."
      invalidText="Number is not valid"
    />

@2nikhiltom 2nikhiltom requested a review from a team as a code owner July 26, 2024 10:38
Copy link

netlify bot commented Jul 26, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e58cd56
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/66bc7fa194300300081b1b5d
😎 Deploy Preview https://deploy-preview-17048--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jul 26, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit e58cd56
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/66bc7fa1abe96300084b36a1
😎 Deploy Preview https://deploy-preview-17048--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just on my end or it is having performance issues? The screen freezes sometimes and then crash.
Screenshot 2024-08-13 at 09 44 19

@2nikhiltom
Copy link
Contributor Author

2nikhiltom commented Aug 13, 2024

Hey @guidari
This is interesting and happening on my system too. It can be seen on Production as well.
Note: Happens on Playground story only, when Steppers (+/-)are clicked rapidly. Should we open a separate bug for this? - Will now be tracked via #17164

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Let's open a new issue for the the performance then!

@alisonjoseph alisonjoseph added this pull request to the merge queue Aug 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 13, 2024
@2nikhiltom 2nikhiltom added this pull request to the merge queue Aug 14, 2024
Merged via the queue into carbon-design-system:main with commit 3788b98 Aug 14, 2024
22 checks passed
@2nikhiltom 2nikhiltom deleted the fix_16865_numberInput_step branch August 14, 2024 10:35
@carbon-automation
Copy link
Contributor

Hey there! v11.64.0 was just released that references this issue/PR.

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

Successfully merging this pull request may close these issues.

[Bug]: Unexpected Increment Behavior in NumberInput Component with Step Prop
3 participants