Repository navigation
fix(button)!: default to type="button" - #144
Open
pratikbuilds wants to merge 1 commit into
Open
pratikbuilds wants to merge 1 commit into
pratikbuilds wants to merge 1 commit into
Conversation
Button rendered a native <button> with no type, so HTML treated every bare Button as a submit button: inside a host form, activating it submitted the form. That is the stalled "Load earlier messages" control in ConversationEarlier and the Retry control in SendStatusLine. Button now renders type="button" unless a type is passed. asChild gets no injected type, since the slotted child may not be a button. BREAKING CHANGE: a bare Button no longer submits a form. Pass type="submit" for a submit button. Addresses corbitsdev#142 findings 8 and 9.
TheGreatAxios
requested changes
Oct 30, 2026
TheGreatAxios
left a comment
Contributor
There was a problem hiding this comment.
Review · Request changes
Defaults native Button elements to type="button" when asChild is false so bare buttons inside host forms do not implicitly submit.
Findings
src/ui/button.tsx:80—type={asChild ? undefined : "button"}is placed before{...props}, so a caller or wrapper that forwards{ type: undefined }overwritestype="button"withundefinedand renders a submit button (<button data-slot="button" ...>). Could we destructuretype = asChild ? undefined : "button"inButton's parameters and passtype={type}sotype={undefined}still defaults to"button"?src/ui/button.test.tsx:30(informational) —container.querySelector("button") as HTMLButtonElement(and lines 44, 62) usesasto silence| nullrather than narrowing.
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.
Summary
Buttonrenders a native<button>, and a<button>with notypeis a submit button. Inside a host form, every bareButtonsubmitted the form, including the stalled "Load earlier messages" control inConversationEarlierand Retry inSendStatusLine(findings 8 and 9).Buttonnow renderstype="button"unless atypeis passed. An explicittypestill wins, andasChildgets no injected type, since the slotted child may not be a button.Breaking: a bare
Buttonno longer submits a form. Passtype="submit"for a submit button.Verification
bun run checkbutton.test.tsx: a bareButtonin a form does not submit,type="submit"does, andasChildgets notype.Closes #142