Enter key submits form during streaming because querySelector('button[type="submit"]') returns null
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- frontend
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.
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
- Send a message and wait for the model to start streaming
- Type anything in the textarea and press Enter
- The form submits mid-stream
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 283
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel/ai-elements
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
vercel/ai-elements#494 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vercel/ai-elements#490 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
vercel/ai-elements#486 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/ai-elements#484 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vercel/ai-elements#458 ·
All issues in vercel/ai-elements
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·