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(){ async function indexOnLoad(){
document.body.addEventListener('click', focusBarcodeInput, true);
loadProducts(); loadProducts();
document.querySelector("input[autofocus]").addEventListener("blur", function() { document.querySelector("input[autofocus]").addEventListener("blur", function() {
var t = this; var t = this;
@ -52,6 +53,10 @@ async function indexOnLoad(){
}); });
} }
function focusBarcodeInput(){
document.getElementById('barcode_input').focus()
}
async function loadProducts() { async function loadProducts() {
const loadProductRequest = new Request(api_url + "/products") const loadProductRequest = new Request(api_url + "/products")
all_products = await makeAPIRequest(loadProductRequest) all_products = await makeAPIRequest(loadProductRequest)

View file

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