From 4ae196156bf137c2b651a91322f502e9e8ceb928 Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Wed, 4 Sep 2024 11:59:45 +0200 Subject: [PATCH] Maybe really fixed autofocus issue --- static/scripts/main.js | 5 +++++ templates/index.jinja | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/static/scripts/main.js b/static/scripts/main.js index b093ae2..8fe8ca9 100644 --- a/static/scripts/main.js +++ b/static/scripts/main.js @@ -42,6 +42,7 @@ async function loadCash(price) { } async function indexOnLoad(){ + document.body.addEventListener('click', focusBarcodeInput, true); loadProducts(); document.querySelector("input[autofocus]").addEventListener("blur", function() { var t = this; @@ -52,6 +53,10 @@ async function indexOnLoad(){ }); } +function focusBarcodeInput(){ + document.getElementById('barcode_input').focus() +} + async function loadProducts() { const loadProductRequest = new Request(api_url + "/products") all_products = await makeAPIRequest(loadProductRequest) diff --git a/templates/index.jinja b/templates/index.jinja index dadca13..651c7b4 100644 --- a/templates/index.jinja +++ b/templates/index.jinja @@ -11,7 +11,7 @@ - +