Skip to content

bug:  #21427

@phancox

Description

@phancox

Bug Report

IonButton not reacting to "Enter" on form with react-hook-form. Occurs in browser under chrome, not tried on mobile.

Ionic version:
[x] 5.1.0

Current behavior:
Using IonButton with react-hook-form. When standard <button> is used expected behaviour of running "onSubmit" runs when "Enter" is pressed within a form field. If <button> is changed to <IonButton> then "Enter" does not run onSubmit, the IonButton must be pressed.

Expected behavior:
When <IonButton type="submit"> is placed on react-hook-form and "Enter" is pressed while in form input field, the "onSubmit" function should be run.

Steps to reproduce:
Hope it's OK but I'll reference the code from this article https://medium.com/better-programming/how-to-use-react-hook-form-with-ionic-react-components-eaa4426d8a2d

There is a related CodeSandbox.io project here: https://codesandbox.io/s/react-hook-form-ionic-input-components-29zur

Run the project, complete the form validation, and press "Enter" while in a form input field. Nothing will happen,

Modify the code of the submit button changing <IonButton> to <button> and repeat the exercise.
This time the onSubmit function will run and a popup will display the form fields.

Related code:
As above

Other information:

Ionic info:
This is from my own project which exhibits the same behaviour:

Ionic:

Ionic CLI : 6.9.3 (/usr/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.1.0

Capacitor:

Capacitor CLI : 2.0.1
@capacitor/core : 2.0.1

Utility:

cordova-res : not installed
native-run : not installed

System:

NodeJS : v12.17.0 (/usr/bin/node)
npm : 6.14.4
OS : Linux 4.19

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions