fix: prevent Enter from submitting during IME composition
Added compositionstart/compositionend event listeners to track IME composing state. Enter key now only submits when not composing, so Chinese/Japanese/Korean input methods work correctly.
This commit is contained in:
parent
cc4c6fe346
commit
66d0901938
|
|
@ -211,7 +211,7 @@ html,body{height:100%;font-family:var(--font);background:var(--bg);color:var(--t
|
|||
</div>
|
||||
<div class="input-area">
|
||||
<div class="input-wrap">
|
||||
<textarea id="input" rows="1" placeholder="输入消息..." onkeydown="handleKey(event)" oninput="autoResize(this)"></textarea>
|
||||
<textarea id="input" rows="1" placeholder="输入消息..." onkeydown="handleKey(event)" oninput="autoResize(this)" oncompositionstart="inputComposing=true" oncompositionend="inputComposing=false"></textarea>
|
||||
<button class="btn-send" id="sendBtn" onclick="sendMessage()">发送</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -466,8 +466,10 @@ async function sendMessage() {
|
|||
updateSendBtn();
|
||||
}
|
||||
|
||||
let inputComposing = false;
|
||||
|
||||
function handleKey(e) {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !inputComposing) {
|
||||
e.preventDefault();
|
||||
sendMessage();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue