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

Holding decrement button on useNumberInput causes new inputs to count down to min value #4646

Closed
1 of 3 tasks
aaronkik opened this issue Aug 30, 2021 · 2 comments
Closed
1 of 3 tasks
Labels
needs triage Issues and pull requests that need triage attention Type: Bug 🐛 Something isn't working

Comments

@aaronkik
Copy link

aaronkik commented Aug 30, 2021

Description

Holding decrement button with a min value until the button is disabled on useNumberInput causes new inputs to count down to the min value

Link to Reproduction

https://codesandbox.io/s/use-number-input-bug-oxyy6?file=/src/index.js

Steps to reproduce

  1. Set a min value for the useNumberInput
  2. Enter a number slightly greater than the min value in the input field
  3. Click and hold the decrement button until the current input value has reached the min value and the decrement button is disabled
  4. Type in another number greater than the min value
  5. Watch the current input value decrement without any user input

Chakra UI Version

1.6.7

Browser

Google Chrome 92.0.4515.159

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

It appears when hovering the mouse over any of the buttons while the value is auto decrementing appears to stop the bug.

@TheThirdRace
Copy link

You can also reproduce the problem within Chakra doc: https://chakra-ui.com/docs/form/number-input#create-a-mobile-spinner

Simply repeat the behavior with the mobile spinner and it has this exact problem.


On another note, I would inquiry if the disable behavior is a11y compliant?

As far as I'm aware, it's discouraged to disable buttons nowadays because it doesn't give the user a context as to why it's disabled.

It really doesn't matter that you can still press the button while the minimum is reached. It could easily be optimized to stop calling the whole process of decreasing the counter within the internal state if the minimum is reached.

On the other hand, what does matter is having the rug pulled from under your feet. While using the keyboard to press the minus button, the moment the button becomes disabled the focus switches to the input. It must be highly disorienting for people with disabilities. Their context changes out of "nowhere" and I'm pretty sure the voice over must also announce the change too, adding to the disorientation.

So if the disabling mechanic is interfering with what's causing this problem, maybe it would be better to re-evaluate the whole process in a more a11y way. Food for thoughts...

@anubra266
Copy link
Collaborator

will be fixed in #4982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issues and pull requests that need triage attention Type: Bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants