Mishig commited on
Commit
6d68eb5
1 Parent(s): 73a5c0d

[Chat input] Fix asian keyboards (#789)

Browse files
src/lib/components/chat/ChatInput.svelte CHANGED
@@ -11,6 +11,7 @@
11
 
12
  let innerWidth = 0;
13
  let textareaElement: HTMLTextAreaElement;
 
14
 
15
  const dispatch = createEventDispatcher<{ submit: void }>();
16
 
@@ -19,7 +20,7 @@
19
 
20
  function handleKeydown(event: KeyboardEvent) {
21
  // submit on enter
22
- if (event.key === "Enter" && !event.shiftKey) {
23
  event.preventDefault();
24
  dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 14
25
  }
@@ -50,6 +51,8 @@
50
  bind:this={textareaElement}
51
  {disabled}
52
  on:keydown={handleKeydown}
 
 
53
  on:keypress
54
  {placeholder}
55
  />
 
11
 
12
  let innerWidth = 0;
13
  let textareaElement: HTMLTextAreaElement;
14
+ let isCompositionOn = false;
15
 
16
  const dispatch = createEventDispatcher<{ submit: void }>();
17
 
 
20
 
21
  function handleKeydown(event: KeyboardEvent) {
22
  // submit on enter
23
+ if (event.key === "Enter" && !event.shiftKey && !isCompositionOn) {
24
  event.preventDefault();
25
  dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 14
26
  }
 
51
  bind:this={textareaElement}
52
  {disabled}
53
  on:keydown={handleKeydown}
54
+ on:compositionstart={() => (isCompositionOn = true)}
55
+ on:compositionend={() => (isCompositionOn = false)}
56
  on:keypress
57
  {placeholder}
58
  />