From 7f70f0ec07b0ac554a1071f9d33913ed1f2722eb Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 17 Aug 2021 17:48:45 +0200 Subject: [PATCH] Fixed chore/battery camera barcode scanning blur event handling (fixes #1585) --- changelog/63_UNRELEASED_xxxx.xx.xx.md | 1 + public/viewjs/batterytracking.js | 15 ++++++++++++++- public/viewjs/choretracking.js | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/changelog/63_UNRELEASED_xxxx.xx.xx.md b/changelog/63_UNRELEASED_xxxx.xx.xx.md index 001aa5f2..20989d3d 100644 --- a/changelog/63_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/63_UNRELEASED_xxxx.xx.xx.md @@ -6,4 +6,5 @@ - Fixed that the "Stock by-barcode" API routes also accepted chore or battery grocycodes (thanks @lowlee) - Fixed that it was not possible to select a chore/battery on the corresponding tracking pages by mouse/touch - Fixed that grouping by columns in tables may caused duplicate groups +- Fixed that grocycode camera barcode scanning didn't recognize the scanned code for chore/battery tracking - Optimized the meal plan page to be properly printable (thanks @MrKrisKrisu) diff --git a/public/viewjs/batterytracking.js b/public/viewjs/batterytracking.js index f410fc74..e96fbb48 100644 --- a/public/viewjs/batterytracking.js +++ b/public/viewjs/batterytracking.js @@ -105,7 +105,20 @@ $(document).on("Grocy.BarcodeScanned", function(e, barcode, target) return; } - $('#battery_id_text_input').val(barcode).trigger('change'); + // Don't know why the blur event does not fire immediately ... this works... + $("#battery_id_text_input").focusout(); + $("#battery_id_text_input").focus(); + $("#battery_id_text_input").blur(); + + $("#battery_id_text_input").val(barcode); + + setTimeout(function() + { + $("#battery_id_text_input").focusout(); + $("#battery_id_text_input").focus(); + $("#battery_id_text_input").blur(); + Grocy.Components.DateTimePicker.GetInputElement().focus(); + }, 200); }); function UndoChargeCycle(chargeCycleId) diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js index 6cc3d286..e155be1c 100644 --- a/public/viewjs/choretracking.js +++ b/public/viewjs/choretracking.js @@ -121,7 +121,20 @@ $(document).on("Grocy.BarcodeScanned", function(e, barcode, target) return; } - $('#chore_id_text_input').val(barcode).trigger('change'); + // Don't know why the blur event does not fire immediately ... this works... + $("#chore_id_text_input").focusout(); + $("#chore_id_text_input").focus(); + $("#chore_id_text_input").blur(); + + $("#chore_id_text_input").val(barcode); + + setTimeout(function() + { + $("#chore_id_text_input").focusout(); + $("#chore_id_text_input").focus(); + $("#chore_id_text_input").blur(); + Grocy.Components.DateTimePicker.GetInputElement().focus(); + }, 200); }); Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e)