diff --git a/packages/html2/src/index.ts b/packages/html2/src/index.ts
index 2afcb49..9401169 100644
--- a/packages/html2/src/index.ts
+++ b/packages/html2/src/index.ts
@@ -57,7 +57,13 @@ export class Widget implements EventTarget {
}
}
+ const wasFocus = oldNode && document.activeElement === oldNode;
oldNode?.parentNode?.replaceChild(newNode, oldNode);
+ if (wasFocus) {
+ if (newNode && newNode instanceof HTMLElement) {
+ newNode.focus();
+ }
+ }
this.node.value = newNode;
}