webui: make input box focus on page load
Add a window.load event listener in the firstUpdated lifecycle method to ensure
the chat input gets focused when the page loads completely.
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/webui/src/web-components/sketch-chat-input.ts b/webui/src/web-components/sketch-chat-input.ts
index 257c583..fb273bc 100644
--- a/webui/src/web-components/sketch-chat-input.ts
+++ b/webui/src/web-components/sketch-chat-input.ts
@@ -141,6 +141,17 @@
// Initialize the input height
this.adjustChatSpacing();
}
+
+ // Add window.onload handler to ensure the input is focused when the page fully loads
+ window.addEventListener(
+ "load",
+ () => {
+ if (this.chatInput) {
+ this.chatInput.focus();
+ }
+ },
+ { once: true },
+ );
}
render() {