-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: omit keypress with ctrlKey or altKey (#615)
- Loading branch information
1 parent
2b0632a
commit 391e513
Showing
3 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import userEvent from '../../index' | ||
import {setup} from '../helpers/utils' | ||
|
||
test('no character input if `altKey` or `ctrlKey` is pressed', () => { | ||
const {element, eventWasFired} = setup(`<input/>`) | ||
;(element as HTMLInputElement).focus() | ||
|
||
userEvent.keyboard('[ControlLeft>]g') | ||
|
||
expect(eventWasFired('keypress')).toBe(false) | ||
expect(eventWasFired('input')).toBe(false) | ||
|
||
userEvent.keyboard('[AltLeft>]g') | ||
|
||
expect(eventWasFired('keypress')).toBe(false) | ||
expect(eventWasFired('input')).toBe(false) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
391e513
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a bug in this change?
I updated my React project this morning and updated @testing-library along with it. Now my tests of elements using 'onKeyPress' are failing.
Where previously userEvent.type would fire a keypress event, now no keypress event is fired.
391e513
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We previously triggered some ’keypress’ events that don't happen in the browser.
See #613
If you have different observations, please share the details on the issue.
Should there be new problems introduced by these changes, please file a new issue with a reproduction example.
Thanks for your help. :)