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
userEvent.clear()
does not fire onChange
handlers
#268
Comments
I'm getting |
Looks like Lines 128 to 130 in ee8aa5c
I didn't write this or review these PRs so I'm not sure why it's working this way (I expect there's some reason for this). In general, I think our goal is to match what cypress does to do these kinds of things. If someone wants to investigate and make sure we're following what cypress does. This may be as simple as also firing a |
Thanks @kentcdodds . First, I verified performing The Line 215 in ee8aa5c
I'm happy to open a PR to immediately fire an diff --git a/src/index.js b/src/index.js
index 352ce9e..c9e23c8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -100,11 +100,6 @@ function selectOption(select, option) {
fireEvent.change(select);
}
-function fireChangeEvent(event) {
- fireEvent.change(event.target);
- event.target.removeEventListener("blur", fireChangeEvent);
-}
-
const userEvent = {
click(element) {
const focusedElement = element.ownerDocument.activeElement;
@@ -237,7 +232,7 @@ const userEvent = {
});
}
}
- element.addEventListener("blur", fireChangeEvent);
+ fireEvent.change(event);
},
tab({ shift = false, focusTrap = document } = {}) { |
I'd love to know why that code existed in the first place. But as the original maintainer of this project seems to have stopped maintaining it, I think we should just go forward with what makes the most sense. Go ahead and make the PR. Thank you! |
I think this issue should have been auto closed by #286. I recon it's the extra "issue" word after the "Resolves" Github keyword which has prevent the auto close trigger. |
Reproduction: https://github.com/justinanastos/user-event-clear-bug
I'm finding that
onChange
handlers are not being fired when usinguserEvent.clear(getBy...)
.This is both a bug report and a request for help. I'm not sure what I'm doing wrong here:
The text was updated successfully, but these errors were encountered: