Show empty input when serving size is cleared#1431
Conversation
PR Validation ResultsChange Detection
❌ Required Actions (1)
|
There was a problem hiding this comment.
Code Review
This pull request introduces a custom NumericInput component to improve numeric field handling, updates nutrient form types to use undefined instead of empty strings or nulls, adds a Nix development environment, and refactors Docker configurations. While these changes improve consistency, several issues need to be addressed: a falsy check on calories in NutrientFormGrid.tsx will incorrectly clear the input when the value is 0; changing the nutrient type to undefined in useFoodForm.tsx causes clearing fields to evaluate to NaN in updateVariant; and mounting the host directory directly to /var/lib/postgresql in docker-compose.dev.yml can lead to permission and configuration conflicts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| POSTGRES_PASSWORD: ${SPARKY_FITNESS_DB_PASSWORD:?Variable is required and must be set} | ||
| volumes: | ||
| - ./docker_volume/postgresql:/var/lib/postgresql/data:z | ||
| - ./docker_volume/postgresql18:/var/lib/postgresql:z |
There was a problem hiding this comment.
Mounting the host directory directly to /var/lib/postgresql instead of /var/lib/postgresql/data is highly discouraged for the official PostgreSQL Docker image. This can cause permission issues on the root of the volume and may overwrite or conflict with internal configuration files and the home directory of the postgres user inside the container. It is recommended to use a subdirectory like /var/lib/postgresql/data.
- ./docker_volume/postgresql18:/var/lib/postgresql/data:zThere was a problem hiding this comment.
Mounting postgresql/data directly throws error for me in Docker for postgres.
There was a problem hiding this comment.
sparkyfitness-db | Error: in 18+, these Docker images are configured to store database data in a
sparkyfitness-db | format which is compatible with "pg_ctlcluster" (specifically, using
sparkyfitness-db | major-version-specific directory names). This better reflects how
sparkyfitness-db | PostgreSQL itself works, and how upgrades are to be performed.
sparkyfitness-db |
sparkyfitness-db | See also docker-library/postgres#1259
sparkyfitness-db |
sparkyfitness-db | Counter to that, there appears to be PostgreSQL data in:
sparkyfitness-db | /var/lib/postgresql/data (unused mount/volume)
sparkyfitness-db |
sparkyfitness-db | This is usually the result of upgrading the Docker image without
sparkyfitness-db | upgrading the underlying database using "pg_upgrade" (which requires both
sparkyfitness-db | versions).
sparkyfitness-db |
sparkyfitness-db | The suggested container configuration for 18+ is to place a single mount
sparkyfitness-db | at /var/lib/postgresql which will then place PostgreSQL data in a
sparkyfitness-db | subdirectory, allowing usage of "pg_upgrade --link" without mount point
sparkyfitness-db | boundary issues.
sparkyfitness-db |
sparkyfitness-db | See docker-library/postgres#37 for a (long)
sparkyfitness-db | discussion around this process, and suggestions for how to do so.
| @@ -1,4 +1,4 @@ | |||
| #!/bin/bash | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
note: Nix stores bin files in its immutable stores; so, /bin/bash does not exist there. Using env bash should work across platforms.
4bdee6a to
d286d3a
Compare
| id={gridId(variantIndex, key)} | ||
| label={`${cn.name} (${cn.unit})`} | ||
| value={variant.custom_nutrients?.[cn.name] ?? ''} | ||
| value={typeof value === 'number' ? value : undefined} |
There was a problem hiding this comment.
note: Custom nutrients also only work with numbers but its type still allows for string value. I did not change it here as it required even bigger refactor. If you like this direction for type safety, I can do this in a separate PR.
a320c27 to
caa844d
Compare
| const hasMedia = | ||
| /!\[.*?\]\(.+?\)/i.test(body) || | ||
| /<(?:img|video)\s/i.test(body) || | ||
| /\[[^\]]+\]\([^)]*\.(?:apng|avif|gif|jpe?g|mov|mp4|png|svg|webm)(?:[?#][^)]*)?\)/i.test(body) |
There was a problem hiding this comment.
note: Videos in Github markdown are just markdown links displayed as embedded videos. So, added a regex that support video as well.
There was a problem hiding this comment.
@CodeWithCJ it seems like pr-validation workflow is not being triggered from the PR. Would it make sense to create a separate PR for it; so, screenshots support videos; then rebase this PR for validation to pass?
2a4fd3d to
01a38e0
Compare
- Use NumericInput for number inputs in variant card - Always use `undefined` or number values for variant nutrition fields - Add Nix dev shell for easy development on NixOS
01a38e0 to
bec13b7
Compare
|
@apedley @Sim-sat Could you review this PR. @GasimGasimzada I dont use Flake. if I dont update, it could get outdated. so not sure if I include it!!!! Also could you take a look at the co-pilot comment SparkyFitness/SparkyFitnessFrontend/src/hooks/Foods/useFoodForm.tsx Lines 640 to 656 in 7d049a4
|
|
@CodeWithCJ The fix Copilot suggested is already there. I may have force pushed while fixing linter errors, which confused it. |


Description
undefinedor number values for variant nutrition fieldsAdd Nix dev shell for easy development on NixOS. Removed nix flake files but kept some of the bash scripts to work with bash regardless of bash path (makes my life easier in NixOS without issues in macOS or other linux distros)What problem does this PR solve?
When input field is cleared in serving size, the output value becomes "0" and one cannot remove it. This PR fixes that and allows the input to become empty.
How did you implement the solution?
nulland string types)\Linked Issue: No attached issue.
How to Test
PR Type
Checklist
All PRs:
Frontend changes (
SparkyFitnessFrontend/):pnpm run validateand it passes.UI changes (components, screens, pages):
Screenshots
Click to expand
Before
Kooha-2026-06-02-20-02-37.webm
After
Kooha-2026-06-02-20-03-14.webm
Notes for Reviewers