react icon indicating copy to clipboard operation
react copied to clipboard

Fix MarkdownEditor preview button incorrectly triggered form submit event

Open stkao05 opened this issue 2 years ago • 5 comments

Changelog

When the MarkdownEditor was placed inside a form:

<form>
   <MarkdownEditor />
</form>

The preview tab button of the MarkdownEditor would unintentionally trigger the form submit event when clicked, as the button element, by default, has a submit type.

The missing value default and invalid value default are the Submit Button state. HTML Standard - the button element

This PR fixes this issue by explicitly setting the type attribute of the Preview/Write button to be button.

<button type="button" role="tab" aria-selected="true" tabindex="0">Write</button>
<button type="button" role="tab" aria-selected="false" tabindex="-1">Preview</button>

Changed

  • The "Preview" and "Write" button elements would have attributed type="button" set.

Rollout strategy

  • [x] Patch release
  • [ ] Minor release
  • [ ] Major release; if selected, include a written rollout or migration plan

Merge checklist

  • [x] Added/updated tests
  • [ ] Added/updated documentation
  • [ ] Added/updated previews (Storybook)
  • [x] Changes are SSR compatible
  • [x] Tested in Chrome
  • [ ] Tested in Firefox
  • [ ] Tested in Safari
  • [ ] Tested in Edge
  • [ ] Integration tests pass at github/github (Learn more about how to run integration tests)

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

stkao05 avatar Nov 15 '23 05:11 stkao05

🦋 Changeset detected

Latest commit: c824330c2f34e71cc60e98ebc4eb3f1090d4ab43

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Nov 15 '23 05:11 changeset-bot[bot]

hi @mperrotti, did you get a chance to look it? let me know if there is anything I can help

stkao05 avatar Nov 26 '23 16:11 stkao05

@mperrotti thanks for the review. Could this be merge and released?

stkao05 avatar Dec 26 '23 10:12 stkao05

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

github-actions[bot] avatar Feb 24 '24 10:02 github-actions[bot]

hi @mperrotti , any chance to review this?

stkao05 avatar Feb 27 '24 15:02 stkao05

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

github-actions[bot] avatar May 05 '24 20:05 github-actions[bot]