fix: prevent space key from being swallowed in shareable playground chat input#12754
Conversation
The outer div container wrapping the chat textarea had an onKeyDown
handler that called e.preventDefault() for Space and Enter keys without
first checking whether the event originated from the textarea itself.
When a user typed a space in the textarea, the keydown event bubbled up
to the div, triggering e.preventDefault() on the same event object.
This caused the browser to suppress the default action (inserting the
space character), turning typed phrases into one continuous word.
The fix adds the same textarea origin guard that already exists in the
playgroundComponent version of the same handler:
if (target.closest("textarea")) return;
Fixes langflow-ai#12731
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughModified the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings, 1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #12731
Problem
In the shareable playground (
/playground/<flowID>), typing a space in the chat input would be silently dropped, so "this is a phrase" became "thisisaphrase".The root cause: the outer
divcontainer wrapping the textarea has anonKeyDownhandler that callse.preventDefault()for Space and Enter key events. When a user types a space inside the textarea, thekeydownevent bubbles up to the div, ande.preventDefault()is called on the same event object. Because the browser evaluatesdefaultPreventedafter all handlers complete (including bubbled ones), this suppresses the default action of inserting the space character into the textarea.Solution
Add the same guard that already exists in the
playgroundComponentversion of the same handler:The fix only touches
src/frontend/src/modals/IOModal/components/chatView/chatInput/components/input-wrapper.tsx, which is the code path used by the shareable playground page (viaCustomIOModal → IOModal). The sibling component inplaygroundComponent/already had the correct guard.Testing
e.target.closest("textarea")returns the textarea element when events originate from it, so the handler exits early without callinge.preventDefault().onKeyDownhandler still correctly handles Space/Enter when the outer div itself has focus (e.g. keyboard navigation), redirecting focus to the textarea.Summary by CodeRabbit