editor: smart unit suffix — dim on focus, yield to explicit units#479
Merged
Conversation
While editing a numeric field, the unit suffix now visually responds to the draft content: - Plain number / empty: suffix dims to 40% opacity (signals "default unit if you commit a bare number") - Explicit unit typed (hint showing): suffix fades to opacity-0 over 150ms (the conversion hint provides unit feedback instead) - Unparseable text: suffix stays dimmed (field will revert on commit) - At rest: unchanged full-opacity suffix Uses opacity-0 rather than unmounting so the flex layout doesn't jump. The predicate is simply `hint !== null` — it aligns exactly with measurementHint's internal PLAIN_NUMBER guard. Co-Authored-By: Claude Fable 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 does this PR do?
Reduces confusion in unit-typed inputs now that Lingo accepts explicit units (
5 ftin a meters field). Previously the staticmsuffix stayed fully visible next to such a draft, reading as "5 ft m". Now, in bothSliderControlandMetricControl:= 1.52 mLingo hint is the unit feedback.The show/hide predicate is
hint !== null, so it can never disagree withmeasurementHint's plain-number guard.How to test
bun dev, select a wall and open the inspector.5— suffix stays dimmed. Enter commits 5 m.5 ft— suffix fades out as soon as the draft isn't a plain number; the= 1.52 mhint appears. Enter commits 1.52 m and the normal suffix returns.abc) — suffix stays dimmed; Enter reverts the field.%/unitless field (dim only, never hides).ftsuffix.Screenshots / screen recording
N/A — will add a clip if requested (subtle opacity-only change).
Checklist
bun devbun checkto verify)mainbranch🤖 Generated with Claude Code
Note
Low Risk
Inspector-only opacity styling on unit suffixes during text edit; no parsing, commit, or stored-value logic changes.
Overview
MetricControl and SliderControl now treat the inline
displayUnitsuffix differently while the value field is focused, so typed measurements like5 ftin a meters field no longer read as “5 ft m”.During edit mode, a bare number or empty draft keeps the suffix visible but dimmed (
text-muted-foreground/40) to signal the default unit a plain number commits as. WhenmeasurementHintis active (explicit unit / non–plain-number draft that parses), the suffix fades out over 150ms (opacity-0whenhintis set), leaving the= … mhint as the unit feedback. At-rest display is unchanged.The hide/show rule matches
hint !== null, aligned withmeasurementHint’s plain-number guard.Reviewed by Cursor Bugbot for commit 5b4b267. Bugbot is set up for automated code reviews on this repo. Configure here.