fix(BBButton): render type="button" by default and add type prop - #93
Merged
Merged
Conversation
BBButton renders its underlying <button> without a type attribute, and per the HTML spec such a button defaults to type="submit". Any BBButton placed inside a <form> therefore submits it on click, on top of running its own onClick handler. With no onSubmit handler this is a GET to the current URL, i.e. a full page navigation; inside the BBB client that hits the beforeunload handler and can drop the user out of the meeting. Set type="button" on the <button> in every layout branch (circle/squared, stacked and default), matching what other component libraries (MUI, Chakra, Radix) do: a button inside a form must not submit it unless the consumer explicitly asks for that. Closes bigbluebutton#82
BBButton always renders type="button", so a consumer that genuinely wants a submit or reset button has no way to get one: ButtonProps does not accept a type prop, so passing it is rejected by TypeScript and would not reach the DOM node anyway. Expose type?: 'button' | 'submit' | 'reset', defaulting to 'button' so the safe behavior stays the default and submitting a form remains an explicit opt-in. The allowed values live in constants.ts (TYPES, TYPE_VALUES, DEFAULT_TYPE) like the other Button enums, and are documented in the Storybook argTypes and the component README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
type="button"on the underlying<button>in everyBBButtonlayout branch (circle/squared,stackedanddefault), so aBBButtoninside a<form>no longer submits it on click.type?: 'button' | 'submit' | 'reset'prop that defaults to'button', so a consumer who actually wants a submit or reset button can choose one. The allowed values are inconstants.ts(TYPES,TYPE_VALUES,DEFAULT_TYPE), following the other Button enums.type.ts(JSDoc), the StorybookargTypes, and the component README (a new "Submit Button" example and a row in the Props table).Closes Issue(s)
Closes #82