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

When using input type date, onChange is not triggered when the user enters a date less than min. #1633

Open
johannordli opened this issue Dec 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@johannordli
Copy link

Describe the bug
When using input type date, onChange is not triggered when the user enters a date less than min.

To Reproduce
Steps to reproduce the behavior:

const handleChange = vi.fn()
const user = userEvent.setup()
render(
  <input
    type="date"
    title="birthday"
    min="2024-12-06"
    onChange={e => handleChange(e.target.value)}
  />
)

const input = screen.getByTitle("birthday")

await user.click(input)
await waitFor(() => expect(input).toHaveFocus())

await user.keyboard("2024-12-05{Tab}")
expect(handleChange).toHaveBeenCalledWith("2024-12-05")

Expected behavior
onChange should be triggered even if the entered date is lower than min, it works in jsdom, native javascript in the browser and react in the browser.

Device:

  • Version 15.11.7
@johannordli johannordli added the bug Something isn't working label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant