Made autofocus more consistent

This commit is contained in:
Yarne Coppens 2024-09-07 00:03:10 +02:00
parent 717624a922
commit 193703ff5a
2 changed files with 15 additions and 8 deletions

View file

@ -42,15 +42,17 @@ async function loadCash(price) {
} }
async function indexOnLoad(){ async function indexOnLoad(){
document.body.addEventListener('click', focusBarcodeInput, true); // document.body.addEventListener('click', focusBarcodeInput, true);
loadProducts(); loadProducts();
document.querySelector("input[autofocus]").addEventListener("blur", function() {
var t = this; const bardcodeInputField = document.getElementById('barcode_form')
t.focus(); bardcodeInputField.focus()
setTimeout(function() { // Some browsers won't let you do it until
t.focus(); // after the blur has completed bardcodeInputField.addEventListener('blur', function() {
}, 100); setTimeout(() => {
}); bardcodeInputField.focus();
}, 0)
})
} }
function focusBarcodeInput(){ function focusBarcodeInput(){

View file

@ -1,3 +1,8 @@
html, body {
margin: 0;
height: 100%;
}
body{ body{
background-color: #D9F2D0; background-color: #D9F2D0;
} }