From 8bdb74a8e084232c87db5e9b312f220e576b06cf Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 3 May 2023 08:32:49 +0200 Subject: [PATCH] Optimized button click tooltip hide handling (fixes #2206) --- changelog/70_UNRELEASED_xxxx.xx.xx.md | 1 + public/js/grocy.js | 4 +--- public/viewjs/batteriesoverview.js | 4 +--- public/viewjs/choresoverview.js | 4 +--- public/viewjs/mealplan.js | 28 +++++++-------------------- public/viewjs/recipes.js | 4 +--- public/viewjs/shoppinglist.js | 12 +++--------- public/viewjs/stockentries.js | 8 ++------ public/viewjs/stockoverview.js | 8 ++------ public/viewjs/tasks.js | 8 ++------ 10 files changed, 21 insertions(+), 60 deletions(-) diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index 582763e9..9f5ef94b 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -90,6 +90,7 @@ - Added a new `config.php` setting `ENERGY_UNIT` to customize the label to display energy values (was fixed `kcal` before and defaults to that, so no changed behavior when not configured) - Fixed that users were unable to delete their own API keys (when not having the `All permissions` permission) +- Fixed that button tooltips on some places didn't disappear after clicking the corresponding button - New translations: (thanks all the translators) - Romanian (demo available at ) diff --git a/public/js/grocy.js b/public/js/grocy.js index d6d61143..ef39513d 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -1233,9 +1233,7 @@ $('[data-toggle="tooltip"][data-html="true"]').on("shown.bs.tooltip", function() $(document).on("click", "#clear-filter-button", function(e) { - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); }); $(document).on("shown.bs.modal", function(e) diff --git a/public/viewjs/batteriesoverview.js b/public/viewjs/batteriesoverview.js index 3b79d18f..5f07d238 100644 --- a/public/viewjs/batteriesoverview.js +++ b/public/viewjs/batteriesoverview.js @@ -54,9 +54,7 @@ $(document).on('click', '.track-charge-cycle-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); diff --git a/public/viewjs/choresoverview.js b/public/viewjs/choresoverview.js index 431e32ce..b09757de 100644 --- a/public/viewjs/choresoverview.js +++ b/public/viewjs/choresoverview.js @@ -84,9 +84,7 @@ $(document).on('click', '.track-chore-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js index ff15eaba..4e4b3ef0 100644 --- a/public/viewjs/mealplan.js +++ b/public/viewjs/mealplan.js @@ -754,9 +754,7 @@ $(document).on("keydown", "#servings", function(e) $(document).on('click', '.recipe-order-missing-button', function(e) { - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectId = $(e.currentTarget).attr('data-recipe-id'); @@ -820,9 +818,7 @@ $(document).on('click', '.product-consume-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); @@ -868,9 +864,7 @@ $(document).on('click', '.product-consume-button', function(e) $(document).on('click', '.recipe-consume-button', function(e) { - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var objectName = $(e.currentTarget).attr('data-recipe-name'); var objectId = $(e.currentTarget).attr('data-recipe-id'); @@ -925,9 +919,7 @@ $(document).on('click', '.recipe-consume-button', function(e) $(document).on("click", ".display-recipe-button", function(e) { - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var objectId = $(e.currentTarget).attr('data-recipe-id'); var servings = $(e.currentTarget).attr('data-mealplan-servings'); @@ -962,9 +954,7 @@ $(document).on("click", ".display-recipe-button", function(e) $(document).on("click", ".display-product-button", function(e) { - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.Components.ProductCard.Refresh($(e.currentTarget).attr('data-product-id')); $("#mealplan-productcard-modal").modal("show"); @@ -974,9 +964,7 @@ $(document).on("click", ".mealplan-entry-done-button", function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 1 }, @@ -995,9 +983,7 @@ $(document).on("click", ".mealplan-entry-undone-button", function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var mealPlanEntryId = $(e.currentTarget).attr("data-mealplan-entry-id"); Grocy.Api.Put("objects/meal_plan/" + mealPlanEntryId, { "done": 0 }, diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index 34fb17c3..0bde02e2 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -440,9 +440,7 @@ $(document).on('click', '.ingredient-done-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); $(e.currentTarget).parent().toggleClass("text-strike-through"); }); diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 25294200..8afa2b08 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -121,9 +121,7 @@ $(document).on('click', '.shoppinglist-delete-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id'); Grocy.FrontendHelpers.BeginUiBusy(); @@ -253,9 +251,7 @@ $(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', fu { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); var href = $(e.currentTarget).attr('href'); @@ -335,9 +331,7 @@ $(document).on('click', '.order-listitem-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js index 1eae6e7b..649b69c3 100644 --- a/public/viewjs/stockentries.js +++ b/public/viewjs/stockentries.js @@ -61,9 +61,7 @@ $(document).on('click', '.stock-consume-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); @@ -110,9 +108,7 @@ $(document).on('click', '.product-open-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 0590994a..ef3385ba 100755 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -130,9 +130,7 @@ $(document).on('click', '.product-consume-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); @@ -185,9 +183,7 @@ $(document).on('click', '.product-open-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); diff --git a/public/viewjs/tasks.js b/public/viewjs/tasks.js index 3c9e0411..7ad30df2 100644 --- a/public/viewjs/tasks.js +++ b/public/viewjs/tasks.js @@ -54,9 +54,7 @@ $(document).on('click', '.do-task-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy(); @@ -99,9 +97,7 @@ $(document).on('click', '.undo-task-button', function(e) { e.preventDefault(); - // Remove the focus from the current button - // to prevent that the tooltip stays until clicked anywhere else - document.activeElement.blur(); + $(".tooltip").tooltip("hide"); Grocy.FrontendHelpers.BeginUiBusy();