mapbox / mapbox/react-submittable

Button's in forms cause double submits onEnter

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
18
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Because a button's default type is submit and a form will trigger a submit on enter, giving a button inside of <Submittable> an onSubmit callback that is the same as a the required onEnter callback will cause double submit.

This can be prevented by invoking event.preventDefault() inside of the callback, but we might want to look at preventing inside of react-submittable as this seems unexpected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting react-submittable's form and button handling, then reproduce the case where a button's onSubmit callback matches the required onEnter callback and pressing Enter submits twice. Done means the component prevents the duplicate submit without requiring callers to invoke event.preventDefault() themselves.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.