supabase-community / postgres-new

In-browser Postgres sandbox with AI assistance
https://database.build
Apache License 2.0
2.34k stars 183 forks source link

Unintended message sending during IME composition #83

Closed riya-amemiya closed 1 month ago

riya-amemiya commented 2 months ago

Bug report

Describe the bug

When typing in languages that use Input Method Editors (IMEs) such as Japanese, Chinese, or Korean, pressing the Enter key to confirm the IME conversion unintentionally sends the message. The system doesn't distinguish between normal Enter key presses and those used for IME conversion confirmation.

To Reproduce

Steps to reproduce the behavior:

  1. Open the chat interface
  2. Start typing in a language that uses an IME (e.g., Japanese)
  3. Begin the composition process (e.g., type "こんにちは" in hiragana)
  4. Press Enter to confirm the IME conversion
  5. Observe that the message is sent immediately, even though you were only trying to confirm the IME conversion

Expected behavior

The Enter key press should only confirm the IME conversion without sending the message. The message should only be sent when pressing Enter after the IME composition is complete.

Screenshots

[If applicable, add screenshots here to demonstrate the issue]

System information

Additional context

This bug significantly impacts the user experience for users typing in languages that use IMEs. It affects the accessibility and usability of the chat interface for a global audience.

Proposed solution: Add an isComposing check to the keydown event handler to prevent message sending during IME composition. Example code snippet:

onKeyDown={(e) => {
  if (!(e.target instanceof HTMLTextAreaElement)) {
    return
  }

 if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
  // ... rest of the handler

This change would ensure that the Enter key only sends the message when it's not being used for IME composition confirmation.

riya-amemiya commented 1 month ago

fix