File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 11
11
12
12
let innerWidth = 0 ;
13
13
let textareaElement: HTMLTextAreaElement ;
14
+ let isCompositionOn = false ;
14
15
15
16
const dispatch = createEventDispatcher <{ submit: void }>();
16
17
19
20
20
21
function handleKeydown(event : KeyboardEvent ) {
21
22
// submit on enter
22
- if (event .key === " Enter" && ! event .shiftKey ) {
23
+ if (event .key === " Enter" && ! event .shiftKey && ! isCompositionOn ) {
23
24
event .preventDefault ();
24
25
dispatch (" submit" ); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 14
25
26
}
50
51
bind:this ={textareaElement }
51
52
{disabled }
52
53
on:keydown ={handleKeydown }
54
+ on:compositionstart ={() => (isCompositionOn = true )}
55
+ on:compositionend ={() => (isCompositionOn = false )}
53
56
on:keypress
54
57
{placeholder }
55
58
/>
You can’t perform that action at this time.
0 commit comments