Repository navigation
790/food goals bug - #807
Open
ChaoticallyAlys wants to merge 6 commits into
Open
ChaoticallyAlys wants to merge 6 commits into
ChaoticallyAlys wants to merge 6 commits into
Conversation
added 6 commits
November 23, 2026 16:47
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
User edits are reflected once clicking out of the text box editor (onBlur()), so the user can type freely.
Values are recalculated so that they scale according to user changes.
Notifications pop up if user input is out of range.
Changes
nutrition-goals.tsx
User can edit text boxes freely
Clicking out of text boxes immediately recalculates the new goals to keep the values balanced (ex: if a user has a goal of 200 calories, changing to a goal with 30 grams of protein, 500 grams of carbs, and 20 grams of fat should result in a calorie count of 2300 automatically)
Calories Formula: protein * 4 + carbs * 4 + fat * 9 = calories
When Calories change: All three macros scale by the same percentage (ex: increasing Calories by 20% → increases Protein, Carbs, and Fat by 20%)
When a Macro changes: Calories automatically adjust based on the change (ex: decreasing Protein by 1 → decreases Calories by 4)
Validates goals twice to account for two situations:
Before recalculation → user could’ve entered bad input
After recalculation → there is a possibility that recalculation results in Calories < 100
Updates the goals to reflect user changes & calculations
Added Snackbar pop ups to notify user
peterplate/nutrition.ts
nutrition/router.ts
layout-client.tsx
Testing Instructions
NOTE: Because changes scale proportionally, at low and high values the formula doesn’t match due to rounding to the nearest integer.
Test the items below for both Mobile and Desktop view for EACH goal:
Editing in the text box without clicking out of it shows no changes
Editing and clicking out of the text box reflects the saved change
Editing in the text box without clicking out of it but navigating to another page, then navigating back, reflects the saved change
Can type freely in the text box (enter no value, negative values, extremely large values > 10000)
Clicking out of text box results in correct notification of input error
Editing each macros increases/decreases Calories proportionally. Editing:
Protein changes in proportions of *4
Carbs changes in proportions of *4
Fat changes in proportions of *9
Editing Calories increases/decreases macros proportionally (e.g., decreasing Calories by 20% → decreases all macros by 20%)
Closes #790