fix: ignore rating toggle deselection instead of saving an empty rating#65
Merged
Conversation
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.
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.
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-groupdeselects it and emitschangewithvalue === undefined. The guardevent.value < 1did not catch this (undefined < 1isfalsein 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
value === undefined || value === null || value < 1), skip the API call, and restore the previous toggle selection in the UI.onRatingChanged, two-wayngModel) got the same fix; the template now passes ``, and keyboard-driven rating changes (arrow keys / 1-5) keep working via an optional event parameter.Verification
tsc --noEmitclean;ng test --watch=false: 1357 passed, 0 failed.Backend counterpart (root cause of ratings "lost after reload"): alvachien/aclearningutil#3.