Skip to content

fix: block Enter submission when submit button is not in DOM - #478

Open
HankGrimm wants to merge 1 commit into
vercel:mainfrom
HankGrimm:fix/prompt-input-enter-guard-null-submit
Open

fix: block Enter submission when submit button is not in DOM#478
HankGrimm wants to merge 1 commit into
vercel:mainfrom
HankGrimm:fix/prompt-input-enter-guard-null-submit

Conversation

@HankGrimm

Copy link
Copy Markdown

What

Changes the Enter-key guard in PromptInputTextarea from submitButton?.disabled to !submitButton || submitButton.disabled.

Why

When PromptInputSubmit renders as a stop button during streaming (type="button"), form.querySelector('button[type="submit"]') returns null. The old guard evaluates null?.disabled to undefined, which is falsy, so the guard never fires — Enter submits a new message mid-stream.

Note on behavior change

This also means: if a composed PromptInput doesn't render PromptInputSubmit at all, Enter will now always be blocked (no submit button is ever found in the DOM). Flagging this per the discussion on the issue — happy to adjust if a different default is preferred for that composition case.

How verified

Traced the DOM query and type logic; no test suite found for this component (no prompt-input.test.tsx in the repo) — verification is by code reading, not by running tests.

Fixes #439

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@HankGrimm is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

Enter key submits form during streaming because querySelector('button[type="submit"]') returns null

1 participant