-
Notifications
You must be signed in to change notification settings - Fork 249
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
Same file upload doesn't fire input event, even when clearing input.value
#632
Comments
This seems to be an issue with jsdom. See We aren't able to work around this by just setting |
This might also be an issue for |
jsdom seems to implement the correct behaviour for clearing: https://github.com/jsdom/jsdom/blob/bd50bbe219799980d9c9a173309cafcef3d9d8bc/lib/jsdom/living/nodes/HTMLInputElement-impl.js#L416 |
Looking at the getters and setters for value and files there, I'm actually surprised that |
@lucaslcode I have a similar use case where I'd like to clear a file input. I discovered that the userEvent.upload(screen.getByLabelText(/select file/i), file);
userEvent.upload(screen.getByLabelText(/select file/i), (null as unknown) as File);
userEvent.upload(screen.getByLabelText(/select file/i), file); In your example, this would cause the Update You can also pass userEvent.upload(screen.getByLabelText(/select file/i), file);
userEvent.upload(screen.getByLabelText(/select file/i), []);
userEvent.upload(screen.getByLabelText(/select file/i), file); |
The issue has been resolved in #794 https://codesandbox.io/s/solitary-mountain-vlttj?file=/src/index.test.js |
@testing-library/user-event
version: 12.8.2Relevant code or config
What you did:
In #575, upload was changed so it correctly doesn't fire an onChange/onInput event when the same files are selected. In our use case, we do want it to fire again, and our workaround is adding an
onClick
event that setsinputEl.value = ""
.What happened:
Second input event doesn't fire, even when the value is reset to blank.
Problem description:
Looking at the source, it doesn't appear to take
value
into account.Suggested solution:
It should consider the value of the input field, but I'm not sure how the value relates to
input.files
, which is what is normally used.The text was updated successfully, but these errors were encountered: