Repository navigation
[Bug]: Saving an edited meal without changes can change its values #1466
Description
Description
Editing a meal feels unreliable. Values change after opening the edit screen and saving without touching anything, and blank fields behave inconsistently (between micro and macronutrients). Plus combining this with the behavior around changing the base quantity makes the edit page UX feel really unpredictable.
Steps to reproduce
Case A: change nothing at all
- Create a custom meal. Set the nutrition base quantity to 30 g and energy to 7 kcal (carbs/fat/protein optional). Save. The app stores 7 × (100 ÷ 30) = 23.33… kcal per 100 g internally.
- Open this meal in the edit screen. The energy field now shows 23.3 (rounded for display).
- Change nothing. Hit Save.
- The meal now stores 23.3 kcal — the original 23.33… is gone.
Context: I know this exact case feels not that important but it showcases that the entire edit form behavior is unpredictable, sometimes invisible to a user.
Case B: imperial units setting
- With units set to imperial, create a custom meal with meal size 100 g.
- Open it in the edit screen — the size shows 3.53 oz (rounded).
- Change nothing. Hit Save.
- The meal size is now stored as 100.07 g.
Case C: change one field
- Open a custom meal, change only the base quantity from 100 g to 50 g, leave everything else untouched, save.
- Values I never typed (e.g. sugars) are now rescaled — 5 g became 10 g (visible on the meal page).
Case D: blank macro field is different than a blank micro field
- Open a custom meal that has kcal + macros, edit any field, leave fat blank, save.
- Fat is gone.
Expected behaviour
Opening the edit screen and saving without changing anything must leave the meal exactly as it was — regardless of which fields are filled or empty, and regardless of metric/imperial or kcal/kJ settings. A field I didn't touch should keep its value.
I'm undecided on what a blank field should do. What I know:
- it should be consistent for every field
- it should either be communicated to the user or it should be obvious what happens when a field is left blank (or changed to blank)
Actual behaviour
Values are rounded to what the form displays and saved back, so precision is lost on a no-op save (Cases A/B). Untouched values get rescaled when the base quantity changes (Case C). Blank kcal/carbs/fat/protein erase their stored value, while blank sugar/fiber/sodium etc. keep theirs — two different meanings of the same blank field (Case D).
Platform
Android
OS version
Android 12
App version
2.5.0
Install source
GitHub Release
Feature area
Custom meals
Screenshots / recordings
No response
Logs or stack trace
Additional context
Possibly related to #506. Micronutrient values have had several past bugs (#1152, #716 — wrong units/display), so I'm unsure whether the values I see after editing are the ones I stored.
Checklist
- I have searched existing issues and this is not a duplicate
- I am reporting a bug in OpenNutriTracker, not a third-party food database entry error
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsTodo
Activity
Gr3q commentedon Oct 25, 2026
just a note, maybe my Case C is intentional on your end, in that case just dismiss it. But for me it's terrible UX that trips me up every time I change/edit values in a different order compared to top/bottom (and I almost always start with filling out calories/macro for some reason).
Edit: and I can't provide a screenshot to Case A and Case B because it's not visible in the UI, I just dug at the code a bit after I was trying to pin down why the edit page feels hard to use and unpredictable.
fix: preserve untouched custom meal fields exactly to avoid rounding …