@testing-library/user-event 14.0.0-beta.7 β†’ 14.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,8 +14,7 @@
14
14
 
15
15
  <br />
16
16
 
17
- [**Read The Docs**](https://testing-library.com/docs/ecosystem-user-event) |
18
- [Edit the docs](https://github.com/testing-library/testing-library-docs)
17
+ [**Read The Docs**](https://testing-library.com/docs/user-event/intro)
19
18
 
20
19
  <br />
21
20
  </div>
@@ -38,25 +37,6 @@
38
37
  [![Tweet][twitter-badge]][twitter]
39
38
  <!-- prettier-ignore-end -->
40
39
 
41
- ## Table of Contents
42
-
43
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
44
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
45
-
46
- - [The problem](#the-problem)
47
- - [The solution](#the-solution)
48
- - [Installation](#installation)
49
- - [Docs](#docs)
50
- - [Known limitations](#known-limitations)
51
- - [Issues](#issues)
52
- - [πŸ› Bugs](#-bugs)
53
- - [πŸ’‘ Feature Requests](#-feature-requests)
54
- - [❓ Questions](#-questions)
55
- - [Contributors](#contributors)
56
- - [LICENSE](#license)
57
-
58
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
59
-
60
40
  ## The problem
61
41
 
62
42
  From
@@ -74,30 +54,6 @@ change the state of the checkbox.
74
54
  > [The more your tests resemble the way your software is used, the more
75
55
  > confidence they can give you.][guiding-principle]
76
56
 
77
- ## Installation
78
-
79
- With NPM:
80
-
81
- ```sh
82
- npm install --save-dev @testing-library/user-event @testing-library/dom
83
- ```
84
-
85
- With Yarn:
86
-
87
- ```sh
88
- yarn add --dev @testing-library/user-event @testing-library/dom
89
- ```
90
-
91
- ## Docs
92
-
93
- [**Read The Docs**](https://testing-library.com/docs/ecosystem-user-event) |
94
- [Edit the docs](https://github.com/testing-library/testing-library-docs)
95
-
96
- ## Known limitations
97
-
98
- - No `<input type="color" />` support.
99
- [#423](https://github.com/testing-library/user-event/issues/423#issuecomment-669368863)
100
-
101
57
  ## Issues
102
58
 
103
59
  Looking to contribute? Look for the [Good First Issue][good-first-issue] label.
@@ -125,152 +81,10 @@ instead of filing an issue on GitHub.
125
81
 
126
82
  ## Contributors
127
83
 
128
- Thanks goes to these people ([emoji key][emojis]):
129
-
130
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
131
- <!-- prettier-ignore-start -->
132
- <!-- markdownlint-disable -->
133
- <table>
134
- <tr>
135
- <td align="center"><a href="https://twitter.com/Gpx"><img src="https://avatars0.githubusercontent.com/u/767959?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Giorgio Polvara</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3AGpx" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=Gpx" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=Gpx" title="Documentation">πŸ“–</a> <a href="#ideas-Gpx" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="#infra-Gpx" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="https://github.com/testing-library/user-event/pulls?q=is%3Apr+reviewed-by%3AGpx" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/testing-library/user-event/commits?author=Gpx" title="Tests">⚠️</a></td>
136
- <td align="center"><a href="https://github.com/weyert"><img src="https://avatars3.githubusercontent.com/u/7049?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Weyert de Boer</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=weyert" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=weyert" title="Tests">⚠️</a></td>
137
- <td align="center"><a href="https://github.com/twhitbeck"><img src="https://avatars2.githubusercontent.com/u/762471?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim Whitbeck</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Atwhitbeck" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=twhitbeck" title="Code">πŸ’»</a></td>
138
- <td align="center"><a href="https://michaeldeboey.be"><img src="https://avatars3.githubusercontent.com/u/6643991?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MichaΓ«l De Boey</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=MichaelDeBoey" title="Documentation">πŸ“–</a></td>
139
- <td align="center"><a href="https://github.com/michaellasky"><img src="https://avatars2.githubusercontent.com/u/6646599?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michael Lasky</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=michaellasky" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=michaellasky" title="Documentation">πŸ“–</a> <a href="#ideas-michaellasky" title="Ideas, Planning, & Feedback">πŸ€”</a></td>
140
- <td align="center"><a href="https://github.com/shomalgan"><img src="https://avatars0.githubusercontent.com/u/2883620?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmad Esmaeilzadeh</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=shomalgan" title="Documentation">πŸ“–</a></td>
141
- <td align="center"><a href="https://calebeby.ml"><img src="https://avatars1.githubusercontent.com/u/13206945?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Caleb Eby</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=calebeby" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/issues?q=author%3Acalebeby" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/pulls?q=is%3Apr+reviewed-by%3Acalebeby" title="Reviewed Pull Requests">πŸ‘€</a></td>
142
- </tr>
143
- <tr>
144
- <td align="center"><a href="https://afontcu.dev"><img src="https://avatars0.githubusercontent.com/u/9197791?v=4?s=100" width="100px;" alt=""/><br /><sub><b>AdriΓ  Fontcuberta</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Aafontcu" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=afontcu" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=afontcu" title="Code">πŸ’»</a></td>
145
- <td align="center"><a href="https://github.com/skywickenden"><img src="https://avatars2.githubusercontent.com/u/4930551?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sky Wickenden</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Askywickenden" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=skywickenden" title="Code">πŸ’»</a></td>
146
- <td align="center"><a href="https://github.com/bogdanbodnar"><img src="https://avatars2.githubusercontent.com/u/9034868?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bodnar Bogdan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Abogdanbodnar" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=bogdanbodnar" title="Code">πŸ’»</a></td>
147
- <td align="center"><a href="https://zach.website"><img src="https://avatars0.githubusercontent.com/u/1699281?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zach Perrault</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=zperrault" title="Documentation">πŸ“–</a></td>
148
- <td align="center"><a href="https://twitter.com/ryanastelly"><img src="https://avatars1.githubusercontent.com/u/4138357?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Stelly</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=FLGMwt" title="Documentation">πŸ“–</a></td>
149
- <td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=benmonro" title="Code">πŸ’»</a></td>
150
- <td align="center"><a href="https://github.com/GentlemanHal"><img src="https://avatars2.githubusercontent.com/u/415521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christopher Martin</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=GentlemanHal" title="Code">πŸ’»</a></td>
151
- </tr>
152
- <tr>
153
- <td align="center"><a href="http://fullgallop.me"><img src="https://avatars0.githubusercontent.com/u/32252769?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yuancheng Wu</b></sub></a><br /><a href="https://github.com/testing-library/user-event/pulls?q=is%3Apr+reviewed-by%3AYuanchengWu" title="Reviewed Pull Requests">πŸ‘€</a></td>
154
- <td align="center"><a href="https://github.com/maheshjag"><img src="https://avatars0.githubusercontent.com/u/1705603?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MJ</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=maheshjag" title="Documentation">πŸ“–</a></td>
155
- <td align="center"><a href="https://github.com/jmcriffey"><img src="https://avatars0.githubusercontent.com/u/2831294?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeff McRiffey</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jmcriffey" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=jmcriffey" title="Tests">⚠️</a></td>
156
- <td align="center"><a href="http://jagascript.com"><img src="https://avatars0.githubusercontent.com/u/4562878?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jaga Santagostino</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=kandros" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=kandros" title="Tests">⚠️</a></td>
157
- <td align="center"><a href="http://jordy.app"><img src="https://avatars3.githubusercontent.com/u/12712484?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jordyvandomselaar</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jordyvandomselaar" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=jordyvandomselaar" title="Tests">⚠️</a></td>
158
- <td align="center"><a href="https://lyamkin.com"><img src="https://avatars2.githubusercontent.com/u/3854930?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ilya Lyamkin</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=ilyamkin" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=ilyamkin" title="Tests">⚠️</a></td>
159
- <td align="center"><a href="http://todofullstack.com"><img src="https://avatars2.githubusercontent.com/u/4474353?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kenneth LujΓ‘n Rosas</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=klujanrosas" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=klujanrosas" title="Tests">⚠️</a></td>
160
- </tr>
161
- <tr>
162
- <td align="center"><a href="http://thejoemorgan.com"><img src="https://avatars1.githubusercontent.com/u/2388943?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joe Morgan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jsmapr1" title="Code">πŸ’»</a></td>
163
- <td align="center"><a href="https://twitter.com/wachunga"><img src="https://avatars0.githubusercontent.com/u/438545?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Hirtle</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=wachunga" title="Code">πŸ’»</a></td>
164
- <td align="center"><a href="https://github.com/bdh1011"><img src="https://avatars2.githubusercontent.com/u/8446067?v=4?s=100" width="100px;" alt=""/><br /><sub><b>whiteUnicorn</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=bdh1011" title="Code">πŸ’»</a></td>
165
- <td align="center"><a href="https://www.matej.snuderl.si/"><img src="https://avatars3.githubusercontent.com/u/8524109?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Matej Ε nuderl</b></sub></a><br /><a href="https://github.com/testing-library/user-event/pulls?q=is%3Apr+reviewed-by%3AMeemaw" title="Reviewed Pull Requests">πŸ‘€</a></td>
166
- <td align="center"><a href="https://pomb.us"><img src="https://avatars1.githubusercontent.com/u/1911623?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rodrigo Pombo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=pomber" title="Code">πŸ’»</a></td>
167
- <td align="center"><a href="http://github.com/Raynos"><img src="https://avatars3.githubusercontent.com/u/479538?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jake Verbaten</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=Raynos" title="Code">πŸ’»</a></td>
168
- <td align="center"><a href="https://skovy.dev"><img src="https://avatars1.githubusercontent.com/u/5247455?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Spencer Miskoviak</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=skovy" title="Documentation">πŸ“–</a></td>
169
- </tr>
170
- <tr>
171
- <td align="center"><a href="https://proling.ru/"><img src="https://avatars2.githubusercontent.com/u/16336572?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vadim Shvetsov</b></sub></a><br /><a href="#ideas-vadimshvetsov" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/testing-library/user-event/commits?author=vadimshvetsov" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=vadimshvetsov" title="Tests">⚠️</a></td>
172
- <td align="center"><a href="https://github.com/9still"><img src="https://avatars0.githubusercontent.com/u/4924760?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Greg Shtilman</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=9still" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=9still" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/issues?q=author%3A9still" title="Bug reports">πŸ›</a></td>
173
- <td align="center"><a href="https://github.com/rbusquet"><img src="https://avatars1.githubusercontent.com/u/7198302?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ricardo Busquet</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Arbusquet" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=rbusquet" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=rbusquet" title="Tests">⚠️</a></td>
174
- <td align="center"><a href="https://www.linkedin.com/in/dougbacelar/en"><img src="https://avatars3.githubusercontent.com/u/9267678?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Doug Bacelar</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=dougbacelar" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=dougbacelar" title="Tests">⚠️</a></td>
175
- <td align="center"><a href="https://github.com/kayleighridd"><img src="https://avatars3.githubusercontent.com/u/36446015?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kayleigh Ridd</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Akayleighridd" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=kayleighridd" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=kayleighridd" title="Tests">⚠️</a></td>
176
- <td align="center"><a href="https://malcolmkee.com"><img src="https://avatars0.githubusercontent.com/u/24528512?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Malcolm Kee</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=malcolm-kee" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=malcolm-kee" title="Documentation">πŸ“–</a> <a href="https://github.com/testing-library/user-event/commits?author=malcolm-kee" title="Tests">⚠️</a></td>
177
- <td align="center"><a href="https://github.com/kelvinlzhang"><img src="https://avatars3.githubusercontent.com/u/8291294?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kelvinlzhang</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Akelvinlzhang" title="Bug reports">πŸ›</a></td>
178
- </tr>
179
- <tr>
180
- <td align="center"><a href="https://github.com/krzysztof-hellostudio"><img src="https://avatars3.githubusercontent.com/u/1942664?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krzysztof</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Akrzysztof-hellostudio" title="Bug reports">πŸ›</a></td>
181
- <td align="center"><a href="https://github.com/hontas"><img src="https://avatars2.githubusercontent.com/u/1521113?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pontus Lundin</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=hontas" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=hontas" title="Tests">⚠️</a></td>
182
- <td align="center"><a href="https://hudochenkov.com/"><img src="https://avatars2.githubusercontent.com/u/654597?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aleks Hudochenkov</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Ahudochenkov" title="Bug reports">πŸ›</a></td>
183
- <td align="center"><a href="https://github.com/nanivijay"><img src="https://avatars0.githubusercontent.com/u/5945591?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vijay Kumar Otti</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Ananivijay" title="Bug reports">πŸ›</a></td>
184
- <td align="center"><a href="http://tompicton.com"><img src="https://avatars2.githubusercontent.com/u/12588098?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tom Picton</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Atpict" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=tpict" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=tpict" title="Tests">⚠️</a></td>
185
- <td align="center"><a href="https://hung.dev"><img src="https://avatars3.githubusercontent.com/u/8603085?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hung Viet Nguyen</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Anvh95" title="Bug reports">πŸ›</a></td>
186
- <td align="center"><a href="https://nickmccurdy.com/"><img src="https://avatars0.githubusercontent.com/u/927220?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick McCurdy</b></sub></a><br /><a href="#projectManagement-nickmccurdy" title="Project Management">πŸ“†</a> <a href="#question-nickmccurdy" title="Answering Questions">πŸ’¬</a> <a href="https://github.com/testing-library/user-event/commits?author=nickmccurdy" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=nickmccurdy" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=nickmccurdy" title="Documentation">πŸ“–</a></td>
187
- </tr>
188
- <tr>
189
- <td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=timdeschryver" title="Tests">⚠️</a></td>
190
- <td align="center"><a href="https://github.com/ben-dyer"><img src="https://avatars2.githubusercontent.com/u/43922444?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Dyer</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=ben-dyer" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=ben-dyer" title="Tests">⚠️</a></td>
191
- <td align="center"><a href="https://twitter.com/herecydev"><img src="https://avatars1.githubusercontent.com/u/11328618?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dan Kirkham</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=herecydev" title="Code">πŸ’»</a></td>
192
- <td align="center"><a href="https://github.com/Johannesklint"><img src="https://avatars3.githubusercontent.com/u/16774845?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Johannesklint</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=Johannesklint" title="Documentation">πŸ“–</a></td>
193
- <td align="center"><a href="https://github.com/juanca"><img src="https://avatars0.githubusercontent.com/u/841084?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan Carlos Medina</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=juanca" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=juanca" title="Tests">⚠️</a></td>
194
- <td align="center"><a href="https://github.com/WretchedDade"><img src="https://avatars0.githubusercontent.com/u/17183431?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dade Cook</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=WretchedDade" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=WretchedDade" title="Tests">⚠️</a></td>
195
- <td align="center"><a href="https://blog.lourenci.com/"><img src="https://avatars3.githubusercontent.com/u/2339362?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Leandro Lourenci</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=lourenci" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=lourenci" title="Tests">⚠️</a></td>
196
- </tr>
197
- <tr>
198
- <td align="center"><a href="https://github.com/marcosvega91"><img src="https://avatars2.githubusercontent.com/u/5365582?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marco Moretti</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=marcosvega91" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=marcosvega91" title="Tests">⚠️</a></td>
199
- <td align="center"><a href="https://github.com/ybentz"><img src="https://avatars3.githubusercontent.com/u/14811577?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ybentz</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=ybentz" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=ybentz" title="Tests">⚠️</a></td>
200
- <td align="center"><a href="http://www.lemoncode.net/"><img src="https://avatars2.githubusercontent.com/u/4374977?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nasdan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3ANasdan" title="Bug reports">πŸ›</a></td>
201
- <td align="center"><a href="https://github.com/JavierMartinz"><img src="https://avatars1.githubusercontent.com/u/1155507?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Javier MartΓ­nez</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=JavierMartinz" title="Documentation">πŸ“–</a></td>
202
- <td align="center"><a href="http://www.visualjerk.de"><img src="https://avatars0.githubusercontent.com/u/28823153?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JΓΆrg Bayreuther</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=visualjerk" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=visualjerk" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=visualjerk" title="Documentation">πŸ“–</a></td>
203
- <td align="center"><a href="https://ko-fi.com/thislucas"><img src="https://avatars0.githubusercontent.com/u/8645841?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lucas Bernalte</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=lucbpz" title="Documentation">πŸ“–</a></td>
204
- <td align="center"><a href="https://github.com/maxnewlands"><img src="https://avatars3.githubusercontent.com/u/1304166?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maxwell Newlands</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=maxnewlands" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=maxnewlands" title="Tests">⚠️</a></td>
205
- </tr>
206
- <tr>
207
- <td align="center"><a href="https://github.com/ph-fritsche"><img src="https://avatars3.githubusercontent.com/u/39068198?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ph-fritsche</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=ph-fritsche" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=ph-fritsche" title="Tests">⚠️</a></td>
208
- <td align="center"><a href="https://github.com/reywright"><img src="https://avatars3.githubusercontent.com/u/708820?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rey Wright</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Areywright" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=reywright" title="Code">πŸ’»</a></td>
209
- <td align="center"><a href="https://github.com/mischnic"><img src="https://avatars1.githubusercontent.com/u/4586894?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Niklas Mischkulnig</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=mischnic" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=mischnic" title="Tests">⚠️</a></td>
210
- <td align="center"><a href="http://pascalduez.me"><img src="https://avatars3.githubusercontent.com/u/335467?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pascal Duez</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=pascalduez" title="Code">πŸ’»</a></td>
211
- <td align="center"><a href="http://malachi.dev"><img src="https://avatars3.githubusercontent.com/u/10888943?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Malachi Willey</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=malwilley" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=malwilley" title="Tests">⚠️</a></td>
212
- <td align="center"><a href="https://clarkwinters.com"><img src="https://avatars2.githubusercontent.com/u/40615752?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Clark Winters</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=cwinters8" title="Documentation">πŸ“–</a></td>
213
- <td align="center"><a href="https://github.com/lazytype"><img src="https://avatars1.githubusercontent.com/u/840985?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lazytype</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=lazytype" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=lazytype" title="Tests">⚠️</a></td>
214
- </tr>
215
- <tr>
216
- <td align="center"><a href="https://www.linkedin.com/in/luis-takahashi/"><img src="https://avatars0.githubusercontent.com/u/19766035?v=4?s=100" width="100px;" alt=""/><br /><sub><b>LuΓ­s Takahashi</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=luistak" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=luistak" title="Tests">⚠️</a></td>
217
- <td align="center"><a href="https://github.com/jesujcastillom"><img src="https://avatars3.githubusercontent.com/u/7827281?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jesu Castillo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jesujcastillom" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=jesujcastillom" title="Tests">⚠️</a></td>
218
- <td align="center"><a href="https://sarahdayan.dev"><img src="https://avatars1.githubusercontent.com/u/5370675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sarah Dayan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=sarahdayan" title="Documentation">πŸ“–</a></td>
219
- <td align="center"><a href="http://saul-mirone.github.io/"><img src="https://avatars0.githubusercontent.com/u/10047788?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mirone</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3ASaul-Mirone" title="Bug reports">πŸ›</a></td>
220
- <td align="center"><a href="https://github.com/amandapouget"><img src="https://avatars3.githubusercontent.com/u/12855692?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amanda Pouget</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=amandapouget" title="Documentation">πŸ“–</a></td>
221
- <td align="center"><a href="https://github.com/Sonic12040"><img src="https://avatars3.githubusercontent.com/u/21055893?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sonic12040</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Documentation">πŸ“–</a></td>
222
- <td align="center"><a href="https://github.com/gndelia"><img src="https://avatars1.githubusercontent.com/u/352474?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gonzalo D'Elia</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Documentation">πŸ“–</a></td>
223
- </tr>
224
- <tr>
225
- <td align="center"><a href="https://github.com/vasilii-kovalev"><img src="https://avatars0.githubusercontent.com/u/10310491?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vasilii Kovalev</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=vasilii-kovalev" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=vasilii-kovalev" title="Documentation">πŸ“–</a></td>
226
- <td align="center"><a href="https://www.daleseo.com"><img src="https://avatars1.githubusercontent.com/u/5466341?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dale Seo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=daleseo" title="Documentation">πŸ“–</a></td>
227
- <td align="center"><a href="http://www.alex-boyce.me/"><img src="https://avatars.githubusercontent.com/u/4050934?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alex Boyce</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=curiosity26" title="Code">πŸ’»</a></td>
228
- <td align="center"><a href="https://benadamstyles.com"><img src="https://avatars.githubusercontent.com/u/4380655?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Styles</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=benadamstyles" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=benadamstyles" title="Tests">⚠️</a></td>
229
- <td align="center"><a href="http://laurabeatris.com"><img src="https://avatars.githubusercontent.com/u/48022589?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laura Beatris</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=LauraBeatris" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=LauraBeatris" title="Tests">⚠️</a></td>
230
- <td align="center"><a href="https://twitter.com/boriscoder"><img src="https://avatars.githubusercontent.com/u/812240?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Boris Serdiuk</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Ajust-boris" title="Bug reports">πŸ›</a></td>
231
- <td align="center"><a href="https://bozdoz.com"><img src="https://avatars.githubusercontent.com/u/1410985?v=4?s=100" width="100px;" alt=""/><br /><sub><b>bozdoz</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=bozdoz" title="Documentation">πŸ“–</a> <a href="https://github.com/testing-library/user-event/issues?q=author%3Abozdoz" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=bozdoz" title="Tests">⚠️</a></td>
232
- </tr>
233
- <tr>
234
- <td align="center"><a href="https://github.com/jKatt"><img src="https://avatars.githubusercontent.com/u/5550790?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Kattelans</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jKatt" title="Code">πŸ’»</a></td>
235
- <td align="center"><a href="https://github.com/schoeneu"><img src="https://avatars.githubusercontent.com/u/3261341?v=4?s=100" width="100px;" alt=""/><br /><sub><b>schoeneu</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Aschoeneu" title="Bug reports">πŸ›</a></td>
236
- <td align="center"><a href="https://github.com/mkapal"><img src="https://avatars.githubusercontent.com/u/6420535?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martin Kapal</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Amkapal" title="Bug reports">πŸ›</a></td>
237
- <td align="center"><a href="https://gr.linkedin.com/in/bastakis"><img src="https://avatars.githubusercontent.com/u/1146626?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stavros</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Asstauross" title="Bug reports">πŸ›</a></td>
238
- <td align="center"><a href="https://github.com/geoffroymounier"><img src="https://avatars.githubusercontent.com/u/24386870?v=4?s=100" width="100px;" alt=""/><br /><sub><b>geoffroymounier</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Ageoffroymounier" title="Bug reports">πŸ›</a></td>
239
- <td align="center"><a href="https://fergusmcdonald.com"><img src="https://avatars.githubusercontent.com/u/3115675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fergus McDonald</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=fergusmcdonald" title="Code">πŸ’»</a></td>
240
- <td align="center"><a href="https://github.com/robin-ambachtsheer"><img src="https://avatars.githubusercontent.com/u/2611873?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robin Ambachtsheer</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Arobin-ambachtsheer" title="Bug reports">πŸ›</a></td>
241
- </tr>
242
- <tr>
243
- <td align="center"><a href="https://github.com/MohitPopli"><img src="https://avatars.githubusercontent.com/u/17976072?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mohit</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3AMohitPopli" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=MohitPopli" title="Code">πŸ’»</a> <a href="https://github.com/testing-library/user-event/commits?author=MohitPopli" title="Tests">⚠️</a></td>
244
- <td align="center"><a href="https://github.com/InExtremaRes"><img src="https://avatars.githubusercontent.com/u/1635491?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Contreras</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3AInExtremaRes" title="Bug reports">πŸ›</a></td>
245
- <td align="center"><a href="https://eugene.coding.blog"><img src="https://avatars.githubusercontent.com/u/13572283?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eugene Ghanizadeh</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=loreanvictor" title="Code">πŸ’»</a></td>
246
- <td align="center"><a href="https://github.com/vicrep"><img src="https://avatars.githubusercontent.com/u/11432241?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Victor Repkow</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=vicrep" title="Code">πŸ’»</a></td>
247
- <td align="center"><a href="https://github.com/GreenGremlin"><img src="https://avatars.githubusercontent.com/u/647452?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan Felchlin</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=GreenGremlin" title="Code">πŸ’»</a></td>
248
- <td align="center"><a href="https://github.com/sydneyjodon-wk"><img src="https://avatars.githubusercontent.com/u/51122966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sydneyjodon-wk</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Asydneyjodon-wk" title="Bug reports">πŸ›</a> <a href="https://github.com/testing-library/user-event/commits?author=sydneyjodon-wk" title="Code">πŸ’»</a></td>
249
- <td align="center"><a href="https://github.com/codepath2019"><img src="https://avatars.githubusercontent.com/u/49729798?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charles Magic Woo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Acodepath2019" title="Bug reports">πŸ›</a></td>
250
- </tr>
251
- <tr>
252
- <td align="center"><a href="https://github.com/mkurcius"><img src="https://avatars.githubusercontent.com/u/1613212?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mkurcius</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=mkurcius" title="Code">πŸ’»</a></td>
253
- <td align="center"><a href="http://stderr.timfischbach.de"><img src="https://avatars.githubusercontent.com/u/26554?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim Fischbach</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Atf" title="Bug reports">πŸ›</a></td>
254
- <td align="center"><a href="https://github.com/eventualbuddha"><img src="https://avatars.githubusercontent.com/u/1938?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brian Donovan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=eventualbuddha" title="Code">πŸ’»</a></td>
255
- <td align="center"><a href="http://www.largetimber.com"><img src="https://avatars.githubusercontent.com/u/10626756?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eric Wang</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=fa93hws" title="Code">πŸ’»</a></td>
256
- <td align="center"><a href="https://github.com/jesperorb"><img src="https://avatars.githubusercontent.com/u/21122051?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jesper Orb</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jesperorb" title="Code">πŸ’»</a></td>
257
- <td align="center"><a href="https://johannesfischer.github.io/"><img src="https://avatars.githubusercontent.com/u/28100?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Johannes Fischer</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=JohannesFischer" title="Code">πŸ’»</a></td>
258
- <td align="center"><a href="https://github.com/777PolarFox777"><img src="https://avatars.githubusercontent.com/u/19393384?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrew D.</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=777PolarFox777" title="Code">πŸ’»</a></td>
259
- </tr>
260
- <tr>
261
- <td align="center"><a href="https://github.com/patricklizon"><img src="https://avatars.githubusercontent.com/u/12571855?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patrick LizoΕ„</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=patricklizon" title="Code">πŸ’»</a></td>
262
- </tr>
263
- </table>
264
-
265
- <!-- markdownlint-restore -->
266
- <!-- prettier-ignore-end -->
267
-
268
- <!-- ALL-CONTRIBUTORS-LIST:END -->
269
-
270
- This project follows the [all-contributors][all-contributors] specification.
271
- Contributions of any kind welcome!
84
+ We most sincerely thank [the people who make this project
85
+ possible][contributors]. Contributions of any kind are welcome! πŸ’š
272
86
 
273
- ## LICENSE
87
+ ## License
274
88
 
275
89
  [MIT](LICENSE)
276
90
 
@@ -297,8 +111,6 @@ Contributions of any kind welcome!
297
111
  [github-star]: https://github.com/testing-library/user-event/stargazers
298
112
  [twitter]: https://twitter.com/intent/tweet?text=Check%20out%20user-event%20by%20%40@TestingLib%20https%3A%2F%2Fgithub.com%2Ftesting-library%2Fuser-event%20%F0%9F%91%8D
299
113
  [twitter-badge]: https://img.shields.io/twitter/url/https/github.com/testing-library/user-event.svg?style=social
300
- [emojis]: https://github.com/all-contributors/all-contributors#emoji-key
301
- [all-contributors]: https://github.com/all-contributors/all-contributors
302
114
  [all-contributors-badge]: https://img.shields.io/github/all-contributors/testing-library/user-event?color=orange&style=flat-square
303
115
  [guiding-principle]: https://twitter.com/kentcdodds/status/977018512689455106
304
116
  [bugs]: https://github.com/testing-library/user-event/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug
@@ -308,4 +120,5 @@ Contributions of any kind welcome!
308
120
  [discord-badge]: https://img.shields.io/discord/723559267868737556.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
309
121
  [discord]: https://discord.gg/testing-library
310
122
  [stackoverflow]: https://stackoverflow.com/questions/tagged/user-event
123
+ [contributors]: https://github.com/testing-library/user-event/blob/beta/CONTRIBUTORS.md
311
124
  <!-- prettier-ignore-end -->
package/dist/index.cjs CHANGED
@@ -1072,15 +1072,30 @@ function readSelectedValueFromInput(target) {
1072
1072
  return val.substring(sel.startOffset, sel.endOffset);
1073
1073
  }
1074
1074
 
1075
+ // src/utils/misc/findClosest.ts
1076
+ function findClosest(element, callback) {
1077
+ let el = element;
1078
+ do {
1079
+ if (callback(el)) {
1080
+ return el;
1081
+ }
1082
+ el = el.parentElement;
1083
+ } while (el && el !== element.ownerDocument.body);
1084
+ return void 0;
1085
+ }
1086
+
1075
1087
  // src/utils/focus/focus.ts
1076
1088
  function focus(element) {
1077
- if (!isFocusable(element))
1078
- return;
1079
- const isAlreadyActive = getActiveElement(element.ownerDocument) === element;
1080
- if (isAlreadyActive)
1089
+ const target = findClosest(element, isFocusable);
1090
+ const activeElement = getActiveElement(element.ownerDocument);
1091
+ if ((target != null ? target : element.ownerDocument.body) === activeElement) {
1081
1092
  return;
1082
- eventWrapper(() => element.focus());
1083
- updateSelectionOnFocus(element);
1093
+ } else if (target) {
1094
+ eventWrapper(() => target.focus());
1095
+ } else {
1096
+ eventWrapper(() => activeElement == null ? void 0 : activeElement.blur());
1097
+ }
1098
+ updateSelectionOnFocus(target != null ? target : element.ownerDocument.body);
1084
1099
  }
1085
1100
 
1086
1101
  // src/utils/misc/isVisible.ts
@@ -1281,18 +1296,6 @@ function getErrorMessage(expected, found, text) {
1281
1296
  for more information about how userEvent parses your input.`;
1282
1297
  }
1283
1298
 
1284
- // src/utils/misc/findClosest.ts
1285
- function findClosest(element, callback) {
1286
- let el = element;
1287
- do {
1288
- if (callback(el)) {
1289
- return el;
1290
- }
1291
- el = el.parentElement;
1292
- } while (el && el !== element.ownerDocument.body);
1293
- return void 0;
1294
- }
1295
-
1296
1299
  // src/utils/misc/getDocumentFromNode.ts
1297
1300
  function getDocumentFromNode(el) {
1298
1301
  return isDocument(el) ? el : el.ownerDocument;
@@ -2394,8 +2397,7 @@ function mousedownDefaultBehavior({
2394
2397
  node,
2395
2398
  offset
2396
2399
  }) {
2397
- var _a;
2398
- focus((_a = findClosest(target, isFocusable)) != null ? _a : target.ownerDocument.body);
2400
+ focus(target);
2399
2401
  if (!targetIsDisabled) {
2400
2402
  const hasValue = isElementType(target, ["input", "textarea"]);
2401
2403
  const text = String(hasValue ? getUIValue(target) : target.textContent);
@@ -2777,8 +2779,8 @@ async function upload(element, fileOrFiles) {
2777
2779
  return;
2778
2780
  await this.click(element);
2779
2781
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? void 0 : 1);
2780
- blur(element);
2781
- focus(element);
2782
+ blur(input);
2783
+ focus(input);
2782
2784
  if (files.length === ((_a = input.files) == null ? void 0 : _a.length) && files.every((f, i) => {
2783
2785
  var _a2;
2784
2786
  return f === ((_a2 = input.files) == null ? void 0 : _a2.item(i));
package/dist/index.mjs CHANGED
@@ -1084,15 +1084,30 @@ function readSelectedValueFromInput(target) {
1084
1084
  return val.substring(sel.startOffset, sel.endOffset);
1085
1085
  }
1086
1086
 
1087
+ // src/utils/misc/findClosest.ts
1088
+ function findClosest(element, callback) {
1089
+ let el = element;
1090
+ do {
1091
+ if (callback(el)) {
1092
+ return el;
1093
+ }
1094
+ el = el.parentElement;
1095
+ } while (el && el !== element.ownerDocument.body);
1096
+ return void 0;
1097
+ }
1098
+
1087
1099
  // src/utils/focus/focus.ts
1088
1100
  function focus(element) {
1089
- if (!isFocusable(element))
1090
- return;
1091
- const isAlreadyActive = getActiveElement(element.ownerDocument) === element;
1092
- if (isAlreadyActive)
1101
+ const target = findClosest(element, isFocusable);
1102
+ const activeElement = getActiveElement(element.ownerDocument);
1103
+ if ((target != null ? target : element.ownerDocument.body) === activeElement) {
1093
1104
  return;
1094
- eventWrapper(() => element.focus());
1095
- updateSelectionOnFocus(element);
1105
+ } else if (target) {
1106
+ eventWrapper(() => target.focus());
1107
+ } else {
1108
+ eventWrapper(() => activeElement == null ? void 0 : activeElement.blur());
1109
+ }
1110
+ updateSelectionOnFocus(target != null ? target : element.ownerDocument.body);
1096
1111
  }
1097
1112
 
1098
1113
  // src/utils/misc/isVisible.ts
@@ -1293,18 +1308,6 @@ function getErrorMessage(expected, found, text) {
1293
1308
  for more information about how userEvent parses your input.`;
1294
1309
  }
1295
1310
 
1296
- // src/utils/misc/findClosest.ts
1297
- function findClosest(element, callback) {
1298
- let el = element;
1299
- do {
1300
- if (callback(el)) {
1301
- return el;
1302
- }
1303
- el = el.parentElement;
1304
- } while (el && el !== element.ownerDocument.body);
1305
- return void 0;
1306
- }
1307
-
1308
1311
  // src/utils/misc/getDocumentFromNode.ts
1309
1312
  function getDocumentFromNode(el) {
1310
1313
  return isDocument(el) ? el : el.ownerDocument;
@@ -2424,8 +2427,7 @@ function mousedownDefaultBehavior({
2424
2427
  node,
2425
2428
  offset
2426
2429
  }) {
2427
- var _a;
2428
- focus((_a = findClosest(target, isFocusable)) != null ? _a : target.ownerDocument.body);
2430
+ focus(target);
2429
2431
  if (!targetIsDisabled) {
2430
2432
  const hasValue = isElementType(target, ["input", "textarea"]);
2431
2433
  const text = String(hasValue ? getUIValue(target) : target.textContent);
@@ -2840,8 +2842,8 @@ function upload(element, fileOrFiles) {
2840
2842
  return;
2841
2843
  yield this.click(element);
2842
2844
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? void 0 : 1);
2843
- blur(element);
2844
- focus(element);
2845
+ blur(input);
2846
+ focus(input);
2845
2847
  if (files.length === ((_a = input.files) == null ? void 0 : _a.length) && files.every((f, i) => {
2846
2848
  var _a2;
2847
2849
  return f === ((_a2 = input.files) == null ? void 0 : _a2.item(i));
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Focus closest focusable element.
3
+ */
1
4
  declare function focus(element: Element): void;
2
5
  export { focus };
@@ -1 +1 @@
1
- export declare function findClosest(element: Element, callback: (e: Element) => boolean): Element | undefined;
1
+ export declare function findClosest<T extends Element>(element: Element, callback: (e: Element) => e is T): T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-beta.7",
3
+ "version": "14.0.0-beta.8",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",