Skip to content

Avoid accidental form submissions #4248

Closed

Description

@fregante

Replaces #3911

Pressing the Enter key while you're in a regular input field will submit the form. This means that if you're typing a message and fat-finger the Enter key, you might have made an irreversible change.

This is not so much of an issue when creating an issue since it can be changed later, but it's a problem when merging PRs and saving file changes on the file edit page. Both of them create commits, possibly on the main branch.

Instead of adding annoying prompts, we have 2 options:

  • disable the enter key in issue/PR/commit title fields
  • re-map the enter key to act as a tab in those fields, so it will merely move the cursor to the textarea

I think the latter is preferable because the former would just feel like the enter key is suddenly broken.

Either way, the form will still be submittable via ctrl+enter as it already is.


The solution probably looks like:

delegate(document, 'the right selector', 'keypress', e => {
	if (e is enter key)
		select('textarea', e.delegateTarget.form).focus();
})

Activity

  1. added
    small
    on Apr 16, 2021
  2. changed the title [-]Avoid unwanted early form submissions by re-mapping the enter key[/-] [+]Avoid accidental form submissions by re-mapping the enter key[/+] on Apr 17, 2021
  3. darkred commented on Apr 18, 2021

    @darkred
    Contributor

    @fregante
    I made PR #4252 following your solution (adding e.preventDefault())
    and renamed the feature as avoid-accidental-submissions .

  4. changed the title [-]Avoid accidental form submissions by re-mapping the enter key[/-] [+]Avoid accidental form submissions[/+] on Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedenhancementsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions