diff --git a/static/messages.js b/static/messages.js index 170952dd..29c8ae40 100644 --- a/static/messages.js +++ b/static/messages.js @@ -2428,7 +2428,9 @@ function showApprovalCard(pending, pendingCount) { card.classList.add("visible"); if (typeof applyLocaleToDOM === "function") applyLocaleToDOM(); const onceBtn = $("approvalBtnOnce"); - if (onceBtn) setTimeout(() => onceBtn.focus({preventScroll: true}), 50); + if (onceBtn && document.activeElement !== $('msg')) { + setTimeout(() => onceBtn.focus({preventScroll: true}), 50); + } } async function respondApproval(choice) { @@ -2864,7 +2866,11 @@ function showClarifyCard(pending) { card.classList.add("visible"); _syncClarifyCollapseButton(card); if (typeof applyLocaleToDOM === "function") applyLocaleToDOM(); - if (input && !sameClarify) setTimeout(() => input.focus({preventScroll: true}), 50); + // Move focus to clarify input synchronously (not in setTimeout) and + // only if the user wasn't mid-type in the composer textarea. + if (input && !sameClarify && document.activeElement !== $('msg')) { + input.focus({preventScroll: true}); + } } async function respondClarify(response) {