Repository navigation
Commit 0b0456a
fix(AiDock): ignore Enter during IME composition (#1365)
* fix(AiDock): ignore Enter during IME composition
The dock input submits on any Enter keydown. With an IME, Enter is also the
key that confirms a conversion, so the question is sent while the user is
still composing. It also leaves text behind: submitQuestion() clears the
field, but the IME commit is still pending, so the committed text lands in
the now-empty input.
Check event.nativeEvent.isComposing before submitting, matching RetryComposer,
DraftBot, CommandPalette, ComposerReferences and ConversationSession.
Fixes #1362
* fix(AiDock): also skip IME Enter that arrives after compositionend
Safari fires compositionend before the Enter keydown for Chinese and
Japanese input, so isComposing is already false there. keyCode is still
229 on that keydown, so check it as well.
Move the check into submitOnEnter() in src/utils/ai-dock-enter.ts so it
can be tested. AiDock.tsx can't be imported under tsx --test because of
its .svg imports.
Related to #1362
---------
Co-authored-by: Tanner Linsley <tannerlinsley@gmail.com>1 parent 2f62e9e commit 0b0456a
3 files changed
Lines changed: 58 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
1988 | 1989 | | |
1989 | 1990 | | |
1990 | 1991 | | |
1991 | | - | |
1992 | | - | |
1993 | | - | |
1994 | | - | |
1995 | | - | |
1996 | | - | |
| 1992 | + | |
1997 | 1993 | | |
1998 | 1994 | | |
1999 | 1995 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments