Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When used with form libraries, control buttons trigger form submission because of lack of type #34

Closed
johnfrommartin opened this issue Apr 14, 2020 · 2 comments
Assignees
Labels

Comments

@johnfrommartin
Copy link

Describe the bug
Forms that have this audio player rendered, will trigger form submission when one of the main control buttons are clicked.

Screen Shot 2020-04-14 at 3 02 04 PM

Warning: You submitted a Formik form using a button with an unspecified `type` attribute.  Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.

Can we have the type specified as "button" to prevent this from happening? e.stopPropagation() will not prevent this behavior from happening.

Suggested Fix:

<button
  aria-label={isPlaying ? 'Pause' : 'Play'}
  type="button" //  <-- Fix
  className="rhap_button-clear rhap_main-controls-button rhap_play-pause-button"
  onClick={this.togglePlay}
>
  {actionIcon}
</button>

Environment

Package version: "react-h5-audio-player": "^3.0.4",
React version: "react": "^16.8.2",
Browser and its version: Chromium
OS and its version: macOS Mojave 10.14.6 (18G95)

@lhz516
Copy link
Owner

lhz516 commented Apr 14, 2020

Good catch! The use case inside a form hasn't been considered before.

Try 3.0.5

@johnfrommartin
Copy link
Author

@lhz516 Works great, thanks!

devz097 added a commit to devz097/react-audioplayer that referenced this issue Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants