[PR #32300] feat: configurable Enter/Shift+Enter send behavior in embedded chat (#32295) #33655

Open
opened 2026-02-21 20:53:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/32300

State: open
Merged: No


Summary

Adds a sendOnEnter option to control whether pressing Enter sends messages or inserts newlines in the embedded chat input.

Closes #32295

Problem

Japanese (and other CJK) IME users expect Enter to insert newlines when composing multi-line messages. Currently, Enter always sends the message, causing accidental sends — especially problematic in production embedded chat deployments.

Solution

Added sendOnEnter prop that flows through ChatInputArea → Chat → ChatWrapper:

  • sendOnEnter=true (default): Enter sends, Shift+Enter inserts newline (existing behavior, no breaking change)
  • sendOnEnter=false: Enter inserts newline, Shift+Enter sends

Configuration

Embed script:

window.difyChatbotConfig = {
  token: 'your-token',
  sendOnEnter: false  // Enter = newline, Shift+Enter = send
}

URL parameter:

/chatbot/TOKEN?sendOnEnter=false

IME Handling

Existing compositionstart/compositionend event handling is preserved. Accidental sends during IME composition are prevented regardless of the sendOnEnter setting.

Changes

File Change
chat-input-area/index.tsx Added sendOnEnter prop; key combo logic now checks setting
chat/index.tsx Pass-through sendOnEnter prop to ChatInputArea
embedded-chatbot/chat-wrapper.tsx Read sendOnEnter from URL params
embed.js / embed.min.js Forward sendOnEnter config to iframe URL

Testing

  • Default behavior unchanged (Enter = send)
  • With sendOnEnter=false: Enter inserts newline, Shift+Enter sends
  • IME composition (Japanese/Korean/Chinese): no accidental sends in either mode
  • History navigation (Cmd+Up/Down) unaffected
**Original Pull Request:** https://github.com/langgenius/dify/pull/32300 **State:** open **Merged:** No --- ## Summary Adds a `sendOnEnter` option to control whether pressing Enter sends messages or inserts newlines in the embedded chat input. Closes #32295 ## Problem Japanese (and other CJK) IME users expect Enter to insert newlines when composing multi-line messages. Currently, Enter always sends the message, causing accidental sends — especially problematic in production embedded chat deployments. ## Solution Added `sendOnEnter` prop that flows through `ChatInputArea → Chat → ChatWrapper`: - **`sendOnEnter=true`** (default): Enter sends, Shift+Enter inserts newline (existing behavior, no breaking change) - **`sendOnEnter=false`**: Enter inserts newline, Shift+Enter sends ### Configuration **Embed script:** ```js window.difyChatbotConfig = { token: 'your-token', sendOnEnter: false // Enter = newline, Shift+Enter = send } ``` **URL parameter:** ``` /chatbot/TOKEN?sendOnEnter=false ``` ### IME Handling Existing `compositionstart`/`compositionend` event handling is preserved. Accidental sends during IME composition are prevented regardless of the `sendOnEnter` setting. ## Changes | File | Change | |------|--------| | `chat-input-area/index.tsx` | Added `sendOnEnter` prop; key combo logic now checks setting | | `chat/index.tsx` | Pass-through `sendOnEnter` prop to ChatInputArea | | `embedded-chatbot/chat-wrapper.tsx` | Read `sendOnEnter` from URL params | | `embed.js` / `embed.min.js` | Forward `sendOnEnter` config to iframe URL | ## Testing - Default behavior unchanged (Enter = send) - With `sendOnEnter=false`: Enter inserts newline, Shift+Enter sends - IME composition (Japanese/Korean/Chinese): no accidental sends in either mode - History navigation (Cmd+Up/Down) unaffected
yindo added the pull-request label 2026-02-21 20:53:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33655