-
Notifications
You must be signed in to change notification settings - Fork 251
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
selectOptions triggers change twice #917
Comments
my current walk around to be able to update to v14 is:
|
Thanks for the report. One is dispatched in the utility: user-event/src/utility/selectOptions.ts Line 68 in 6d36828
The other one is from the automatic user-event/src/document/index.ts Lines 43 to 56 in 6d36828
https://codesandbox.io/s/epic-tereshkova-wqodx2?file=/src/App.js |
The Other editable elements with a But it looks like there was a false assumption on when the browser registers the "initial value" to determine if the value was changed: So we might be able to hit two birds with one stone here: document.body.innerHTML=`<input/>`
const input = document.querySelector('input')
input.addEventListener('change', console.log)
input.addEventListener('keydown', e => { if(e.key === 'x') {
e.target.value += 'X'
e.preventDefault()
}}) |
🎉 This issue has been resolved in version 14.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Can confirm it fixed broken tests and didn't introduce any new ones. Thanks for fast fix :) |
Reproduction example
https://codesandbox.io/s/gracious-tess-xtusee?file=/src/App.test.js
Prerequisites
<select onChange={handleChange}>
elementsselectOptions
for one, then another (or call for one then douserEvent.tab()
)Expected behavior
onChange is called one time
Actual behavior
onChange
is called twice. First time when selecting option, second time when changing option for other<select/>
or tabbing out.User-event version
14.0.4
Additional context
This was not a problem in v13: https://codesandbox.io/s/crazy-bas-1vvrhy?file=/src/App.test.js
The text was updated successfully, but these errors were encountered: