Fixed autofocus on barcode input

This commit is contained in:
Yarne Coppens 2024-09-04 11:52:18 +02:00
parent 1c056d85ef
commit 3bed47458f
2 changed files with 13 additions and 2 deletions

View file

@ -41,6 +41,17 @@ async function loadCash(price) {
}
async function indexOnLoad(){
loadProducts();
document.querySelector("input[autofocus]").addEventListener("blur", function() {
var t = this;
t.focus();
setTimeout(function() { // Some browsers won't let you do it until
t.focus(); // after the blur has completed
}, 100);
});
}
async function loadProducts() {
const loadProductRequest = new Request(api_url + "/products")
all_products = await makeAPIRequest(loadProductRequest)

View file

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