Skip to content

fix: ignore rating toggle deselection instead of saving an empty rating#65

Merged
alvachien merged 2 commits into
mainfrom
fix/rating-persistence
Jul 25, 2026
Merged

fix: ignore rating toggle deselection instead of saving an empty rating#65
alvachien merged 2 commits into
mainfrom
fix/rating-persistence

Conversation

@alvachien

Copy link
Copy Markdown
Owner

Problem

In the rating column of the learning pages (chinese-exercises, knowledge-exercises-list, translate-exercises, vocabulary-exercises), clicking the already-active toggle of a mat-button-toggle-group deselects it and emits change with value === undefined. The guard event.value < 1 did not catch this (undefined < 1 is false in JS), so an empty rating was sent to the API, which rejected it with a 400 — silently, since failures were only logged to the console.

Changes

  • All four rating-column handlers now detect deselection (value === undefined || value === null || value < 1), skip the API call, and restore the previous toggle selection in the UI.
  • The vocabulary study-queue rating (onRatingChanged, two-way ngModel) got the same fix; the template now passes ``, and keyboard-driven rating changes (arrow keys / 1-5) keep working via an optional event parameter.
  • Added 6 regression tests across the four pages.
  • Bump version to 1.8.423, releasedate 2026-07-24.

Verification

  • tsc --noEmit clean; ng test --watch=false: 1357 passed, 0 failed.

Backend counterpart (root cause of ratings "lost after reload"): alvachien/aclearningutil#3.

Clicking the active toggle in a mat-button-toggle-group deselects it and
emits change with value undefined, which slipped past the 'value < 1'
guard (undefined < 1 is false) and sent an empty rating to the API,
where it was rejected with a silent 400. Now deselection is detected,
no save is attempted, and the previous selection is restored in the UI.

Applied to the rating columns of chinese-exercises,
knowledge-exercises-list, translate-exercises and vocabulary-exercises,
plus the vocabulary study-queue rating (keyboard-driven rating changes
keep working via an optional event parameter). Added regression tests
for all handlers.

- Bump version to 1.8.423, releasedate 2026-07-24.
@alvachien
alvachien merged commit c82bb3e into main Jul 25, 2026
2 checks passed
@alvachien
alvachien deleted the fix/rating-persistence branch July 25, 2026 01:05
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.

1 participant