question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Form not submitting during "Enter" press when multiple ion-input inside of form.

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

When a single ion-input is inside a form with a submit button, pressing enter while focused inside of that input submits the form.

When multiple ion-input are inside a form with a submit button, pressing enter in either input does not submit the form.

Expected Behavior

No matter how many inputs are inside of a form when a submit button is present, pressing enter inside of them should submit the form.

Steps to Reproduce

Add 2 ion-input to a form, with a ion-button type=“submit”.

<form action="javascript:void(0)" onsubmit="checkSubmit()">
  <ion-item>
    <ion-label position="stacked">Type anything, then press Enter:</ion-label>
    <ion-input />
  </ion-item>
  <ion-item style="--padding-start: 0">
    <ion-label position="stacked">Another Input:</ion-label>
    <ion-input />
  </ion-item>
  <ion-button type="submit" class="ion-margin-top">
    Submit
  </ion-button>
</form>

Code Reproduction URL

https://jsfiddle.net/nmfer04s/

Ionic Info

N/A

Additional Information

I believe this is a regression, it was working when I was using Ionic 5.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mattstevecommented, Mar 26, 2022

The “correct” default behavior is what’s in the spec. E.g. mimic what a raw HTML form does. It’s not important what you want specifically in your application. You can always change default be whatever you want, as you mentioned.

This bug is to get HTML forms working to spec, and working how they should work to meet WAI ARIA WCAG 2.0 accessibility compliance. People with disabilities rely on memorizing a HTML form’s default behaviors; they have to use everyone’s website, not just yours (using screen readers for blindness, or using special controllers for people with motor disabilities that emulate keyboard controls).

For a single line text box, the expectation is that Return or Enter submits the form. https://www.w3.org/TR/wai-aria-1.1/#aria-multiline https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/textbox_role#aria-multiline https://www.digitala11y.com/textbox-role/

0reactions
ionitron-bot[bot]commented, Apr 28, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is preventing my form to be submitted on enter key press?
The default behavior of the keydown event is to submit the form. Example with preventDefault : document.querySelector('input').
Read more >
ion-input: Custom Input Value Type Styling and CSS Properties
ion-input is a wrapper to the HTML input element, with custom value type styling and ... In Angular, this is done automatically through...
Read more >
The Enter Key should Submit Forms, Stop Suppressing it
Basically, if the user hits enter when a text field is focused, the browser should find the first submit button in the form...
Read more >
react hook form two submit buttons - You.com | The AI Search ...
React JS Multiple submit Buttons react-hook-form ... click }else{ //form is submited by pressing enter key // do your code to handle enter...
Read more >
Forms And Validation In Ionic React - Smashing Magazine
While there are already so many React form helpers available to choose from, most of them do not work with Ionic's form components....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found