vercel / vercel/ai-elements

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

Open Beginner friendly
#439 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.4k
Forks
283
Avg merge
32m
Merged PRs (30d)
1

Description

Bug

When PromptInputSubmit is in the generating/streaming state it renders with
type="button" instead of type="submit" to act as a stop button. This means
form.querySelector('button[type="submit"]') in PromptInputTextarea returns
null.

The Enter key guard checks submitButton?.disabled, which evaluates to
undefined when submitButton is null — so the guard never fires and
form.requestSubmit() is called anyway, allowing users to submit a new message
while the model is still streaming.

Fix

// before
if (submitButton?.disabled) {

// after
if (!submitButton || submitButton.disabled) {
No submit button in the DOM → we're in stop/generating mode → block submission.

Steps to reproduce

  1. Send a message and wait for the model to start streaming
  2. Type anything in the textarea and press Enter
  3. The form submits mid-stream

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in PromptInputTextarea and trace the Enter-key guard that queries the form for button[type="submit"], alongside PromptInputSubmit's generating/streaming state. Verify the behavior when no submit button is present, then reproduce the streaming scenario and confirm Enter no longer calls form.requestSubmit() mid-stream.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.