Repository navigation
fix: hide the rating badge and stop a stray "0" when a book's rating is 0 - #616
Merged
Merged
Conversation
…is 0 In JSX, `rating && rating > 0 && (...)` evaluates to 0 when the rating is 0, and React renders it, leaving a stray "0" on the card. - Book card and details view: guard the rating badge with `rating != null && rating > 0`. - Details view: same guard for the duration line, which also printed a bare "0" for a 0-minute runtime. - BookDate recommendation card: convert the rating (a string such as "4.50" from the database) to a number once and show the badge only when it is above 0. - Tests for each spot, with a helper that finds bare "0" text nodes. Closes #615 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What changed
rating != null && rating > 0, so a 0 rating shows nothing instead of a bare "0".Why
In JSX,
rating && rating > 0 && (...)evaluates to0when the rating is 0, and React renders that number. That is the stray "0" in the corner of some search result cards.I checked the other
{value && (...)}guards insrc/on numeric fields. Only the details-view duration could be 0 and print a number. The rest are strings (formatted size and duration labels, counts text), booleans, or already use a ternary or> 0check.Checks
npx vitest related --runon the changed files: 27 files, 259 tests, all pass.npx tsc --noEmit: clean.Risk and rollback
Display-only change in three components. A positive rating and a positive duration render exactly as before. Revert the commit to roll back.
Closes #615
🤖 Generated with Claude Code