From 707788583a2387c1729950e08243d3f8f7049d7c Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 8 May 2025 00:31:21 +0200 Subject: [PATCH] Focus while upload. --- src/snek/static/upload-button.js | 2 ++ src/snek/templates/web.html | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/snek/static/upload-button.js b/src/snek/static/upload-button.js index 0a84705..06563c9 100644 --- a/src/snek/static/upload-button.js +++ b/src/snek/static/upload-button.js @@ -49,6 +49,8 @@ class UploadButtonElement extends HTMLElement { }; request.send(formData); + const uploadEvent = new Event('upload',{}); + this.dispatchEvent(uploadEvent); } channelUid = null connectedCallback() { diff --git a/src/snek/templates/web.html b/src/snek/templates/web.html index 50e30e5..ba2b8fd 100644 --- a/src/snek/templates/web.html +++ b/src/snek/templates/web.html @@ -30,7 +30,7 @@ function getInputField(){ return document.querySelector("textarea") } - + function initInputField(textBox) { textBox.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey) { @@ -42,7 +42,9 @@ } } }); - + document.querySelector("upload-button").addEventListener("upload",function(e){ + getInputField().focus(); + }) textBox.addEventListener("paste", async (e) => { try { const clipboardItems = await navigator.clipboard.read();