Maybe really fixed autofocus issue

This commit is contained in:
Yarne Coppens 2024-09-04 11:59:45 +02:00
parent 3bed47458f
commit 4ae196156b
2 changed files with 6 additions and 1 deletions

View file

@ -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)

View file

@ -11,7 +11,7 @@
<link rel="stylesheet" href="{{url_for('static', filename='style/main.css')}}">
</head>
<body onload="indexOnLoad()">
<body onload="indexOnLoad()" onclick="focusBarcodeInput()">
<form action="" id="barcode_form">
<input id="barcode_input" type="text" autofocus>
<input type="submit" value="Submit">