Fix: allow labels after turning off Allow decimals - #174
Merged
Conversation
Toggling Allow decimals only flipped the flag; the Min/Max fields kept
their decimal-formatted text ("1.0"/"5.0"), which toIntOrNull() cannot
parse. That left minInt/maxInt null and canLabel false, so the label
editor never re-enabled after decimals were switched off.
Reformat the Min/Max fields in the switch's onCheckedChange so whole
numbers are recognised (and the fields match the new step mode).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DzBrHAp8uQ2ddFFbQcGWtM
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
On the category slider-scale screen, the Label values editor never appears when the scale was created with Allow decimals on, even after the user turns decimals back off.
The label editor is gated on
canLabel:When decimals are on, the Min/Max fields are formatted as
"1.0"/"5.0". Toggling Allow decimals off only flips theallowDecimalsflag; the text fields still hold"1.0"/"5.0", and"1.0".toIntOrNull()returnsnull. SominInt/maxIntstaynull,canLabelstaysfalse, and the label rows never render.Fix
Reformat the Min/Max fields inside the switch's
onCheckedChange: strip the trailing.0when decimals are turned off (and re-add it when turned on), so integral values parse as whole numbers and the label editor re-enables. This also keeps the displayed values consistent with the new step mode.Changes
ManageCategoryValuesScreen.kt: reformat Min/Max on the Allow decimals toggle.patch).LESSONS.mdentry: a mode toggle must reformat the text fields whose parsing depends on that mode.Testing
This environment has no Android toolchain, so verification is by inspection of the state flow. After turning decimals off,
minText/maxTextbecome"1"/"5",minInt/maxIntparse to1/5, andcanLabelbecomestrue.🤖 Generated with Claude Code
Generated by Claude Code