Skip to content

Fix cod-button form submit/reset in 3.x#384

Open
arpitjain099 wants to merge 1 commit into
CityOfDetroit:devfrom
arpitjain099:chore/fix-cod-button-form-submit
Open

Fix cod-button form submit/reset in 3.x#384
arpitjain099 wants to merge 1 commit into
CityOfDetroit:devfrom
arpitjain099:chore/fix-cod-button-form-submit

Conversation

@arpitjain099

Copy link
Copy Markdown

This updates cod-button so it can submit and reset parent forms again in 3.x.

What changed:

  • support a type attribute on the component (submit, reset, button, default submit)
  • mirror that type onto the internal native button
  • on click, when inside a form and not disabled/loading/link mode, call the form action directly:
    • requestSubmit() for submit (fallback to submit())
    • reset() for reset

This matches expected button behavior for forms while keeping current link behavior unchanged.

Fixes #352

Tested locally:

  • npx eslint src/stable/components/Button/Button.js
  • npx prettier --check src/stable/components/Button/Button.js
  • npm run build:stable

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirm cod-button submits forms in 3.X

1 participant