Form Submits on Enter Even for Textarea #181

Closed
opened 2018-10-31 11:14:59 -05:00 by chaiim · 1 comment
chaiim commented 2018-10-31 11:14:59 -05:00 (Migrated from github.com)

So it seems like pressing enter always submits a form request. I believe the expected behavior is only when there is one input in a form. But the main issue is just that it submits for textarea inputs instead of allowing the user to continue typing which is the expected behavior of a textarea.

So it seems like pressing enter always submits a form request. I believe the expected behavior is only when there is one input in a form. But the main issue is just that it submits for textarea inputs instead of allowing the user to continue typing which is the expected behavior of a textarea.
BehindTheMath commented 2018-11-11 17:05:56 -05:00 (Migrated from github.com)

Based on the spec:

  • If there is a submit button, or if there's no submit button and there's only 1 blocking input, then Enter in an input will always submit the form.
  • If there's no submit button and there are 2 blocking inputs, Enter will never submit the form.
  • Enter in a textarea will never submit the form.

So the textarea issue is definitely a bug. The input issue is not, if your form has a submit button.

I'm going to remove the unnecessary keyup event listener, and let the browser make the decision when to submit the form.

Based on the [spec](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission): * If there is a submit button, or if there's no submit button and there's only 1 blocking input, then Enter in an input will always submit the form. * If there's no submit button and there are 2 blocking inputs, Enter will never submit the form. * Enter in a textarea will never submit the form. So the textarea issue is definitely a bug. The input issue is not, if your form has a submit button. I'm going to remove the unnecessary `keyup` event listener, and let the browser make the decision when to submit the form.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#181