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);