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

change value of number input when pressing arrow up or down #1272

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Haberkamp
Copy link

@Haberkamp Haberkamp commented Feb 6, 2025

What

With this change you can change the value of a number input by pressing the ArrowUp and ArrowDown key, like so:

await userEvent.type(screen.getByRole('spinbutton'), "{ArrowUp}");

Why

In browsers users are able to increment or decrement the value of a number input when pressing the up or down arrow key.

Adding this to userEvent closes the gap between this package and the browsers.

How

Checks if the input field has a min or max value defined, yes then the value cannot exceed those boundaries. If not the user can increment or decrement the value indefinitely.

If the input field has a step property then it increments or decrements in those steps.

Checklist

  • [N/A] Documentation
  • Tests
  • Ready to be merged

Resolves #1066

Copy link

codesandbox-ci bot commented Feb 6, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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

Successfully merging this pull request may close these issues.

ArrowDown / ArrowUp events in "number" input fields do not trigger onChange
1 participant