Skip to content

fix: hide the rating badge and stop a stray "0" when a book's rating is 0 - #616

Merged
kikootwo merged 1 commit into
mainfrom
fix/615-rating-zero
Nov 16, 2026
Merged

kikootwo merged 1 commit into
mainfrom
fix/615-rating-zero

Conversation

@kikootwo

Copy link
Copy Markdown
Owner

What changed

  • Book card and details view: the rating badge is now guarded with rating != null && rating > 0, so a 0 rating shows nothing instead of a bare "0".
  • Details view: the duration line gets the same guard, since a book with a 0-minute runtime also printed a bare "0".
  • BookDate recommendation card: the rating is turned into a number once (it arrives as a string like "4.50" from the database), and the badge shows only when that number is above 0. Before, a "0.00" rating showed a star and "0.0", and a numeric 0 showed a bare "0".
  • New tests for each spot, plus a small test helper that finds bare text nodes such as "0". The old details-view test only checked for "0.0", so it passed while the bug was live.

Why

In JSX, rating && rating > 0 && (...) evaluates to 0 when 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 in src/ 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 > 0 check.

Checks

  • New tests failed before the fix (6 failures) and pass after.
  • npx vitest related --run on the changed files: 27 files, 259 tests, all pass.
  • npx tsc --noEmit: clean.
  • ESLint on the changed files: no new problems. Each file has the same error and warning count as on main; the new helper is 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

…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>
@kikootwo
kikootwo marked this pull request as ready for review November 16, 2026 01:28
@kikootwo
kikootwo merged commit cb768ef into main Nov 16, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/615-rating-zero branch November 16, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Book card shows a stray 0 when a book's rating is 0

1 participant