fix ask-ai enter

This commit is contained in:
2025-06-15 23:33:22 +09:00
parent d3967c782f
commit 8d960b7a40

View File

@ -253,6 +253,20 @@ function setupAskAIEventListeners() {
handleAIResponse(event.detail); handleAIResponse(event.detail);
}); });
// Track IME composition state
let isComposing = false;
const aiQuestionInput = document.getElementById('aiQuestion');
if (aiQuestionInput) {
aiQuestionInput.addEventListener('compositionstart', function() {
isComposing = true;
});
aiQuestionInput.addEventListener('compositionend', function() {
isComposing = false;
});
}
// Keyboard shortcuts // Keyboard shortcuts
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') { if (e.key === 'Escape') {
@ -263,7 +277,7 @@ function setupAskAIEventListeners() {
} }
// Enter key to send message (only when not composing Japanese input) // Enter key to send message (only when not composing Japanese input)
if (e.key === 'Enter' && e.target.id === 'aiQuestion' && !e.shiftKey && !e.isComposing) { if (e.key === 'Enter' && e.target.id === 'aiQuestion' && !e.shiftKey && !isComposing) {
e.preventDefault(); e.preventDefault();
askQuestion(); askQuestion();
} }