Skip to content

diagram: Enter in the units field saves a newline into the units #829

Open

Description

@bpowers

The units field in the variable and module details panels is a single-line value, but pressing Enter inserts a newline, and that newline is saved into the variable's units.
The equation and notes editors handle Enter deliberately; the units editor only handles Escape.
Enter in the units field should commit the edit (or do nothing), and pasted multi-line text should be flattened.

Example

Type person hours into a variable's units, put the cursor between the words, press Enter, and click away.
The saved units are person\nhours.
The engine joins multi-word unit names only across spaces and tabs (join_multiword_unit_names in src/simlin-engine/src/units.rs), so this likely no longer parses as the unit person_hours (not checked by running it).
A trailing Enter just leaves a \n in the saved model.

Fix

Add an Enter handler to both units <Editable>s that blurs/commits instead of inserting a line, and a small Slate normalizer that merges blocks so paste is covered too.
Alternatively, strip newlines from the units string when the draft is serialized; simpler, but the user still sees the line break while editing.

Pointers

  • src/diagram/VariableDetails.tsx (units <Editable>; its comment already notes the gap)
  • src/diagram/ModuleDetails.tsx (renderUnitsDocsEditors)
  • src/diagram/drawing/common.ts (plainSerialize joins blocks with \n)

Activity

  1. changed the title [-]diagram: units editor accepts Enter, inserting literal newlines into the units string[/-] [+]diagram: Enter in the units field saves a newline into the units[/+] on Oct 12, 2026
  2. added
    frontend
    bug
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions