diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index cec7f8983..31e8570e0 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -5923,49 +5923,31 @@ function _showAiReplyChoice(btn, em, data) { // Full = layered concentric circles to suggest "more, deeper" — not a fully // filled circle so it reads as a complement to the lightning, not as a "stop". menu.innerHTML = ` -
-
- -
-
`; - const modeRow = menu.querySelector('[data-mode-row]'); - const notePanel = menu.querySelector('[data-note-panel]'); const noteInput = menu.querySelector('[data-note-input]'); - let pendingMode = null; + setTimeout(() => noteInput.focus(), 0); menu.addEventListener('click', async (ev) => { const choice = ev.target.closest('[data-mode]'); - if (choice) { - ev.preventDefault(); - ev.stopPropagation(); - // First click reveals the optional-context textarea; the actual - // draft runs on OK. Empty context just runs the chosen mode. - pendingMode = choice.getAttribute('data-mode') || 'ai-reply'; - modeRow.setAttribute('hidden', ''); - notePanel.removeAttribute('hidden'); - setTimeout(() => noteInput.focus(), 0); - return; - } - const ok = ev.target.closest('[data-act="note-ok"]'); - if (ok) { - ev.preventDefault(); - ev.stopPropagation(); - const noteHint = (noteInput.value || '').trim(); - const mode = pendingMode || 'ai-reply'; - _closeAiReplyChoice(); - await _runAiReplyFromButton(btn, em, data, mode, noteHint); - } + if (!choice) return; + ev.preventDefault(); + ev.stopPropagation(); + const mode = choice.getAttribute('data-mode') || 'ai-reply'; + const noteHint = (noteInput.value || '').trim(); + _closeAiReplyChoice(); + await _runAiReplyFromButton(btn, em, data, mode, noteHint); }); // Esc closes the popover; ignore plain clicks inside the menu so the // textarea stays focused.