From 2afffc92afb0f9e4e3171c079d9fbcb97e706d76 Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Sat, 28 Mar 2026 17:26:58 +0100 Subject: [PATCH] fix(messages): 15ms delay for Quill to process keystroke before capture --- static/js/conversations.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/static/js/conversations.js b/static/js/conversations.js index 1bfd1b4..b5f1d00 100644 --- a/static/js/conversations.js +++ b/static/js/conversations.js @@ -1225,18 +1225,22 @@ }, }); - // Enter = send: capture content immediately, clear editor, send async + // Enter = send: let Quill process keystroke first (15ms), then capture+clear+send state.quill.root.addEventListener('keydown', function (e) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); e.stopImmediatePropagation(); - // Snapshot content NOW before Quill processes further keystrokes - var html = state.quill.root.innerHTML; - var text = state.quill.getText().trim(); - if (text) { - state.quill.setText(''); // Clear immediately - Composer.sendContent(html, text); // Send with captured content - } + if (state._pendingSend) return; // Already scheduled + state._pendingSend = true; + setTimeout(function() { + state._pendingSend = false; + var html = state.quill.root.innerHTML; + var text = state.quill.getText().trim(); + if (text) { + state.quill.setText(''); + Composer.sendContent(html, text); + } + }, 15); } }, true);