mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-24 18:50:15 +00:00
fix(webui): prevent approval and clarify cards stealing focus from composer textarea
When tool approval or clarification cards appear during streaming, they unconditionally call focus() on their input elements via setTimeout, stealing focus from the composer (#msg) if the user is actively typing. This silently drops keystrokes mid-type. Add a guard: only move focus to the card if the composer textarea does not already have focus. The document.activeElement check matches the pattern already used upstream in other focus-sensitive components. Fixes: #
This commit is contained in:
committed by
nesquena-hermes
parent
618e1a5da8
commit
32df5546b4
+8
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user