diff --git a/changelog/56_UNRELEASED_2020-xx-xx.md b/changelog/56_UNRELEASED_2020-xx-xx.md index 6e50540e..6cac93f3 100644 --- a/changelog/56_UNRELEASED_2020-xx-xx.md +++ b/changelog/56_UNRELEASED_2020-xx-xx.md @@ -6,5 +6,6 @@ - Optimized the new compact view (there was a little too much white space at the sides of the page) ### Recipe improvements/fixes -- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty - Optimized the ordering of the inputs on the recipe ingredient edit page (moved "Only check if a single unit is in stock" before the amount) +- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty +- Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 05235077..f6e6eb2a 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -381,3 +381,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) // Just save the current recipe on every change of the product picker as a workflow could be started which leaves the page... Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function () { }, function () { }); }); + +// As the /recipe/new route immediately creates a new recipe on load, +// always replace the current location by the created recipes edit page location +if (window.location.pathname.toLowerCase() === "/recipe/new") +{ + window.history.replaceState(null, null, U("/recipe/" + Grocy.EditObjectId)); +}