Skip to content

editor: smart unit suffix — dim on focus, yield to explicit units#479

Merged
Aymericr merged 1 commit into
mainfrom
feat/smart-unit-suffix
Jul 9, 2026
Merged

editor: smart unit suffix — dim on focus, yield to explicit units#479
Aymericr merged 1 commit into
mainfrom
feat/smart-unit-suffix

Conversation

@Aymericr

@Aymericr Aymericr commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Reduces confusion in unit-typed inputs now that Lingo accepts explicit units (5 ft in a meters field). Previously the static m suffix stayed fully visible next to such a draft, reading as "5 ft m". Now, in both SliderControl and MetricControl:

  • Editing, bare number/empty: the suffix dims to 40% opacity — it signals the default unit a bare number commits as.
  • Editing, explicit unit typed: the suffix fades out (150ms opacity, no layout jump) and the existing = 1.52 m Lingo hint is the unit feedback.
  • Unparseable draft: suffix stays dimmed (the field reverts on commit).
  • At rest: unchanged.

The show/hide predicate is hint !== null, so it can never disagree with measurementHint's plain-number guard.

How to test

  1. bun dev, select a wall and open the inspector.
  2. Click a length value: suffix dims. Type 5 — suffix stays dimmed. Enter commits 5 m.
  3. Type 5 ft — suffix fades out as soon as the draft isn't a plain number; the = 1.52 m hint appears. Enter commits 1.52 m and the normal suffix returns.
  4. Type garbage (abc) — suffix stays dimmed; Enter reverts the field.
  5. Repeat in a stair/elevator panel (MetricControl) and on a %/unitless field (dim only, never hides).
  6. Toggle imperial and verify the same behavior with the ft suffix.

Screenshots / screen recording

N/A — will add a clip if requested (subtle opacity-only change).

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

🤖 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 displayUnit suffix differently while the value field is focused, so typed measurements like 5 ft in 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. When measurementHint is active (explicit unit / non–plain-number draft that parses), the suffix fades out over 150ms (opacity-0 when hint is set), leaving the = … m hint as the unit feedback. At-rest display is unchanged.

The hide/show rule matches hint !== null, aligned with measurementHint’s plain-number guard.

Reviewed by Cursor Bugbot for commit 5b4b267. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@Aymericr Aymericr merged commit 5831b7b into main Jul 9, 2026
2 checks passed
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