diff --git a/web/src/structured.ts b/web/src/structured.ts index 56f046f..3651215 100644 --- a/web/src/structured.ts +++ b/web/src/structured.ts @@ -634,10 +634,15 @@ export function createStructuredConnection( // visible flashing and breaks text selection. const oldEl = rowEls.get(delta.row.id); if (oldEl) { + const active = document.activeElement as HTMLElement | null; + const hadToolFocus = active?.classList.contains("st-tool-head") && oldEl.contains(active); const newEl = buildRowElement(delta.row); if (newEl) { oldEl.replaceWith(newEl); rowEls.set(delta.row.id, newEl); + if (hadToolFocus) { + newEl.querySelector(".st-tool-head")?.focus(); + } } syncAvailableCommands(); return;