From 3b09e33b2d61cb0fe78d8f1c2195c8133af32692 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Thu, 4 Sep 2025 17:33:16 -0300 Subject: [PATCH] feat: improve editing --- index.html | 5 +---- src/index.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 89b3cf4..34455ce 100644 --- a/index.html +++ b/index.html @@ -138,11 +138,8 @@ - - -
-

Add Food

+

Add Food Entry

diff --git a/src/index.ts b/src/index.ts index 4802743..9364dc3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -336,6 +336,7 @@ function clearEditing() { searchInput.value = ''; getInputById('gramAmount').value = '100'; showFoodPreview(false); + getDivById('add-foot-title').innerHTML = 'Add Food Entry'; getButtonById('add-food-btn').innerHTML = 'Add Food'; selectedFood = null; } @@ -651,11 +652,21 @@ async function setFoodToEdit(foodId: string) { getInputById('gramAmount').value = foodToEdit[0].grams; previewCalories(foodData) + getDivById('add-foot-title').innerHTML = 'Edit Food Entry'; getButtonById('add-food-btn').innerHTML = 'Save Food'; getInputById('foodIdToUpdate').value = foodId; getInputById('foodTimeToUpdate').value = foodToEdit[0].time; getInputById('foodCaloriesToUpdate').value = foodToEdit[0].calories; + // Scroll to top + const titleDiv = getDivById('add-foot-title') as HTMLElement; + if (titleDiv) { + titleDiv.scrollIntoView({ + behavior: 'smooth', + block: 'start' + }); + } + hideLoading(); } catch (error) { console.error('Set food to edit error:', error);