You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the new userEvent.paste API to test a form in my application. This form intercepts paste events to split contents among numerous fields, so it is critical that it prevents the clipboard contents from being inserted into the focused input field.
What happened:
During the test, the clipboard contents were all inserted into the focused input element. Calling event.preventDefault in the onPaste handler had no effect.
Reproduction repository:
I would be happy to create a reproduction repository if that would be useful, but I saw a similar unit test here in this repository that I might be able to copy as a simpler representation of the problem. I will pursue that first instead.
Problem description:
When using the new userEvent.paste API with the focus on an editable element, calling event.preventDefault in the onPaste handler has no effect. There is no way to prevent the clipboard contents from being inserted into the editable context.
Suggested solution:
As is already the case for other APIs in this library such as upload, the default behavior of the paste event should be skipped if preventDefault is called on the event.
It looks like a similar problem with the upload API was recently fixed in this PR: #847
I am hoping this problem is able to be fixed in a similar manner.
The text was updated successfully, but these errors were encountered:
Gudahtt
added a commit
to Gudahtt/user-event
that referenced
this issue
Feb 24, 2022
@testing-library/user-event
version: 14.0.0-beta.11What you did:
I used the new
userEvent.paste
API to test a form in my application. This form intercepts paste events to split contents among numerous fields, so it is critical that it prevents the clipboard contents from being inserted into the focused input field.What happened:
During the test, the clipboard contents were all inserted into the focused input element. Calling
event.preventDefault
in theonPaste
handler had no effect.Reproduction repository:
I would be happy to create a reproduction repository if that would be useful, but I saw a similar unit test here in this repository that I might be able to copy as a simpler representation of the problem. I will pursue that first instead.
Problem description:
When using the new
userEvent.paste
API with the focus on an editable element, callingevent.preventDefault
in theonPaste
handler has no effect. There is no way to prevent the clipboard contents from being inserted into the editable context.Suggested solution:
As is already the case for other APIs in this library such as
upload
, the default behavior of the paste event should be skipped ifpreventDefault
is called on the event.It looks like a similar problem with the
upload
API was recently fixed in this PR: #847I am hoping this problem is able to be fixed in a similar manner.
The text was updated successfully, but these errors were encountered: