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.

Only one Field exists, press 'enter' trigger submit

See original GitHub issue

for example,

<form className={styles.wrapper} onSubmit={handleSubmit(this.handleSubmit)}> 
   <Field ............................................. >
</form>

tag, press ‘enter’ resulting execute this.handleSubmit but when more than one Field component exist, press ‘enter’ not fire this.handleSubmit

is it possible disable ‘enter’ for submit when one Field exists?

i saw the same issue, but can’t find answer

  • i’m using redux-form 6.5.0 version

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
musbaigcommented, Oct 24, 2017

@highalps One way to disable submitting the form on enter and instead have changes to the field trigger the submit is as follows:

<form className={styles.wrapper} onSubmit={this.props.handleSubmit(() => {})}> 
   <Field ............................................. >
</form>

Then, the Field can use onChange to submit data. I recommend adding the no-op empty function to handleSubmit in case the form uses the onSubmit prop to trigger actions.

1reaction
OKNoahcommented, Sep 26, 2017

@highalps I believe you can put a hidden <button> 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trigger a button click with JavaScript on the Enter key in a text ...
A page can have many forms (but not nested), each having their own submit. Every field of each form will trigger only the...
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 >
It is not able to submit form by typing enter key on text field.
I found bug. If activeform doesnt content the submit button, it is not able to submit form by typing enter key on text...
Read more >
Form Validation with JavaScript
Let's build a simple form with a validation script. The form will include one text field called “Your Name”, and a submit button....
Read more >
How to trigger 'enter' event without pressing enter
How to trigger an 'Enter' event programatically in the backend without pressing enter on the screen but maybe after the user fills in...
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