@testing-library/user-event 14.6.9 → 14.6.10

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.
@@ -18,7 +18,7 @@ registry.behavior.keypress = (event, target, instance)=>{
18
18
  const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
19
19
  if (submit) {
20
20
  return ()=>instance.dispatchUIEvent(submit, 'click');
21
- } else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
21
+ } else if (form && SubmitSingleInputOnEnter.includes(target.type) && Array.from(form.querySelectorAll('input')).filter((el)=>BlockImplicitSubmission.includes(el.type)).length === 1) {
22
22
  return ()=>instance.dispatchUIEvent(form, 'submit');
23
23
  } else {
24
24
  return;
@@ -39,6 +39,21 @@ const ClickInputOnEnter = [
39
39
  'reset',
40
40
  'submit'
41
41
  ];
42
+ // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#field-that-blocks-implicit-submission
43
+ const BlockImplicitSubmission = [
44
+ 'date',
45
+ 'datetime-local',
46
+ 'email',
47
+ 'month',
48
+ 'number',
49
+ 'password',
50
+ 'search',
51
+ 'tel',
52
+ 'text',
53
+ 'time',
54
+ 'url',
55
+ 'week'
56
+ ];
42
57
  const SubmitSingleInputOnEnter = [
43
58
  'email',
44
59
  'month',
@@ -16,7 +16,7 @@ behavior.keypress = (event, target, instance)=>{
16
16
  const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
17
17
  if (submit) {
18
18
  return ()=>instance.dispatchUIEvent(submit, 'click');
19
- } else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
19
+ } else if (form && SubmitSingleInputOnEnter.includes(target.type) && Array.from(form.querySelectorAll('input')).filter((el)=>BlockImplicitSubmission.includes(el.type)).length === 1) {
20
20
  return ()=>instance.dispatchUIEvent(form, 'submit');
21
21
  } else {
22
22
  return;
@@ -37,6 +37,21 @@ const ClickInputOnEnter = [
37
37
  'reset',
38
38
  'submit'
39
39
  ];
40
+ // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#field-that-blocks-implicit-submission
41
+ const BlockImplicitSubmission = [
42
+ 'date',
43
+ 'datetime-local',
44
+ 'email',
45
+ 'month',
46
+ 'number',
47
+ 'password',
48
+ 'search',
49
+ 'tel',
50
+ 'text',
51
+ 'time',
52
+ 'url',
53
+ 'week'
54
+ ];
40
55
  const SubmitSingleInputOnEnter = [
41
56
  'email',
42
57
  'month',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.6.9",
3
+ "version": "14.6.10",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",