diff --git a/changelog/77_UNRELEASED_xxxx-xx-xx.md b/changelog/77_UNRELEASED_xxxx-xx-xx.md
index ef25e8e6..2db0c657 100644
--- a/changelog/77_UNRELEASED_xxxx-xx-xx.md
+++ b/changelog/77_UNRELEASED_xxxx-xx-xx.md
@@ -17,6 +17,7 @@
- A plugin for [Open Food Facts](https://world.openfoodfacts.org/) is now included and used by default (see the `config.php` option `STOCK_BARCODE_LOOKUP_PLUGIN` and maybe change it as needed)
- The product name and image (and of course the barcode itself) are taken over from Open Food Facts to the product being looked up
- Optimized that when moving a product to a freezer location (so when freezing it) the due date will no longer be replaced when the product option "Default due days after freezing" is set to `0`
+- Fixed that a once set quantity unit on a product barcode could not be removed on edit
### Shopping list
diff --git a/public/viewjs/components/productamountpicker.js b/public/viewjs/components/productamountpicker.js
index a9a0d4d2..fb430ebb 100644
--- a/public/viewjs/components/productamountpicker.js
+++ b/public/viewjs/components/productamountpicker.js
@@ -8,6 +8,11 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
if (!Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled)
{
$("#qu_id").find("option").remove().end();
+ if (!$("#qu_id").hasAttr("required"))
+ {
+ $("#qu_id").append('');
+ }
+
$("#qu_id").attr("data-destination-qu-name", FindObjectInArrayByPropertyValue(Grocy.QuantityUnits, 'id', destinationQuId).name);
$("#qu_id").attr("data-destination-qu-name-plural", FindObjectInArrayByPropertyValue(Grocy.QuantityUnits, 'id', destinationQuId).name_plural);
@@ -67,6 +72,11 @@ Grocy.Components.ProductAmountPicker.AllowAnyQu = function(keepInitialQu = false
Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled = true;
$("#qu_id").find("option").remove().end();
+ if (!$("#qu_id").hasAttr("required"))
+ {
+ $("#qu_id").append('');
+ }
+
Grocy.QuantityUnits.forEach(qu =>
{
$("#qu_id").append('');
diff --git a/public/viewjs/productbarcodeform.js b/public/viewjs/productbarcodeform.js
index f0463c09..601d4117 100644
--- a/public/viewjs/productbarcodeform.js
+++ b/public/viewjs/productbarcodeform.js
@@ -92,7 +92,11 @@ if (Grocy.EditMode == "edit")
{
$("#display_amount").val(Grocy.EditObject.amount);
$(".input-group-productamountpicker").trigger("change");
- Grocy.Components.ProductAmountPicker.SetQuantityUnit(Grocy.EditObject.qu_id);
+
+ if (Grocy.EditObject.qu_id)
+ {
+ Grocy.Components.ProductAmountPicker.SetQuantityUnit(Grocy.EditObject.qu_id);
+ }
}
Grocy.FrontendHelpers.ValidateForm('barcode-form');