Skip to content

Commit

Permalink
fix(keyboard): submit form with <button/> on [Enter] (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Dec 13, 2021
1 parent 32c6326 commit eca157a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions src/utils/misc/hasFormSubmit.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export const hasFormSubmit = (
form: HTMLFormElement | null,
): form is HTMLFormElement =>
!!(
form &&
(form.querySelector('input[type="submit"]') ||
form.querySelector('button[type="submit"]'))
!!form?.querySelector(
'input[type="submit"], button:not([type]), button[type="submit"]',
)
9 changes: 4 additions & 5 deletions tests/keyboard/plugin/functional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ cases(
html: `<form><input/><input/><input type="submit"/></form>`,
submit: true,
},
// TODO: submit with button without type attribute
// 'with `<button/>`': {
// html: `<form><input/><input/><button/></form>`,
// submit: true,
// },
'with `<button/>`': {
html: `<form><input/><input/><button/></form>`,
submit: true,
},
'with `<button type="submit"/>`': {
html: `<form><input/><input/><button type="submit"/></form>`,
submit: true,
Expand Down

0 comments on commit eca157a

Please sign in to comment.