Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix (beta): don't send chat message on Enter while composing with IME (CJK) (#12999)

Yuki MIZUNO11fb09e4f40a
diff --git a/src-ui/src/app/components/chat/chat/chat.component.spec.ts b/src-ui/src/app/components/chat/chat/chat.component.spec.ts
index a35117dc5..f7c4134b2 100644
--- a/src-ui/src/app/components/chat/chat/chat.component.spec.ts
+++ b/src-ui/src/app/components/chat/chat/chat.component.spec.ts
@@ -188,4 +188,14 @@ describe('ChatComponent', () => {
component.searchInputKeyDown(event)
expect(component.sendMessage).toHaveBeenCalled()
})
+
+ it('should not send message on Enter key press while composing with IME', () => {
+ jest.spyOn(component, 'sendMessage')
+ const event = new KeyboardEvent('keydown', {
+ key: 'Enter',
+ isComposing: true,
+ })
+ component.searchInputKeyDown(event)
+ expect(component.sendMessage).not.toHaveBeenCalled()
+ })
})
diff --git a/src-ui/src/app/components/chat/chat/chat.component.ts b/src-ui/src/app/components/chat/chat/chat.component.ts
index ca17d4825..0920af027 100644
--- a/src-ui/src/app/components/chat/chat/chat.component.ts
+++ b/src-ui/src/app/components/chat/chat/chat.component.ts
@@ -155,7 +155,10 @@ export class ChatComponent implements OnInit {
}
public searchInputKeyDown(event: KeyboardEvent) {
- if (event.key === 'Enter') {
+ if (
+ event.key === 'Enter' &&
+ !(event.isComposing || event.keyCode === 229)
+ ) {
event.preventDefault()
this.sendMessage()
}