Skip to content

feat(input): name the input's root element after the caller's id - #143

Merged
guyverino merged 1 commit into
masterfrom
feat/input-carries-caller-id
Nov 4, 2026
Merged

guyverino merged 1 commit into
masterfrom
feat/input-carries-caller-id

Conversation

@guyverino

Copy link
Copy Markdown
Collaborator

What & why

MoonInput::new(id) and MoonNumberInput::new(id) take an id, but it only keyed their state: the element they render was keyed by the state entity (("input", entity_id) / ("number-input", entity_id)), a number that changes between launches. By element path every field of a form was MoonUI's inner input-state, so anything that addresses controls by path — the GPUI inspector, a scripted test, MoonTerminal's UI-atlas capture — could not tell one field from another (84 of them in the terminal's atlas collapsed this way).

Changes

  • Input::id(impl Into<ElementId>) and NumberInput::id(..) name the root element. Without a call the root keeps its entity key, so direct users of Input/NumberInput see no change.
  • MoonInput and MoonNumberInput pass their own id to it.
  • docs/component-mirror-baseline.json refreshed for the two touched donor files (input/input.rs, input/number_input.rs). The component API baseline did not change.

Notable decisions

  • The id goes on the existing root rather than on a wrapper div: a wrapper would sit between the caller's flex layout and the input and change its sizing (and break MoonInput::bounds' absolute placement).
  • Uniqueness is the caller's: two siblings with one id share their hover/scroll element state (GPUI does not panic on siblings). In MoonTerminal every literal MoonInput::new id is unique; the one repeat is in a test file.

How to verify

cargo fmt --all -- --check
cargo check -p moon-ui-gallery
cargo test -p moon-ui-components   # 617 passed
cargo test -p moon-ui-gallery      # 9 passed
cargo xtask component-audit --check-baseline
cargo xtask component-api --check-baseline
cargo xtask component-mirror --donor-root vendor/longbridge-gpui-component-ui-src --check-baseline

Checked against MoonTerminal through a local [patch]: build, clippy --workspace --all-targets -D warnings and cargo test --workspace green; a full UI-scene capture of 152 screens differs from the previous one by at most 0.12 % of pixels per screen, and every field now carries the caller's id.

MoonInput and MoonNumberInput take an id but used it only as the key
of their keyed state; the element they drew was keyed by the state
entity (`("input", entity_id)`), a number that differs between
launches. Anything that addresses controls by element path — the
inspector, a scripted test, a docs capture — saw every field of a form
as MoonUI's inner `input-state`, with nothing to tell them apart.

- `Input::id` and `NumberInput::id` name the root element; without one
  the root keeps its entity key, so direct users are unaffected.
- `MoonInput` and `MoonNumberInput` pass their own id there.
- Mirror baseline refreshed for the two touched donor components.
@guyverino
guyverino merged commit f13ac4d into master Nov 4, 2026
4 checks passed
@guyverino
guyverino deleted the feat/input-carries-caller-id branch November 4, 2026 20:28
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