testing-library / testing-library/user-event
.selectOptions triggering onChange on selected option
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction example
https://codesandbox.io/s/unruffled-http-tcih9v?file=/src/App.test.js
Prerequisites
- Run the test in the codesandbox link above.
Expected behavior
When using a native select element, as shown in the codesandbox browser, the onChange is only triggered when the option selected is NOT the currently selected option.
I expect the test to pass and the text "You have selected a new option" not to be in the document.
Actual behavior
The onChange is triggered when selecting the currently selected element and setting showMessage to true.
User-event version
14.1.1
Environment
please see codesandbox.
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction test in the linked CodeSandbox and compare its behavior with a native select element. Trace the selectOptions entry point in this TypeScript project to determine why selecting the already-selected option triggers onChange. Done means the reproduction passes and no message appears when the current option is selected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100