Enter key submits form during streaming because querySelector('button[type="submit"]') returns null
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
- Send a message and wait for the model to start streaming
- Type anything in the textarea and press Enter
- The form submits mid-stream
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.
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