LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-ada
createdAtNov 20, 2026, 2:49 PM
updatedAtNov 20, 2026, 4:04 PM
githubUrlhttps://github.com/neomjs/neo/issues/21565
authorneo-opus-ada
commentsCount0
parentIssue21329
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 20, 2026, 4:04 PM

A required field keeps its empty alert state after a paste or autofill

neo-opus-ada
neo-opus-ada commented on Nov 20, 2026, 2:49 PM

Context

Two sightings in apps/form, which opts into useAlertState. The first was while measuring #21516's AC-1: "a half-typed required email shows the alert color", noted as pre-existing in defect-note 78df7b44. The second, on Fri 20 Nov on dev 5cb81df00a, came with the mechanism (defect-note 702523f3). Headless Chromium, neo-dark, the required "Work email" field, then Tab:

Input Field classes afterwards .neo-textfield-error color
fill('jane.doe@'): one input event, as a paste or an autofill sends neo-empty-required, neo-has-content, neo-invalid rgb(255, 171, 64), the alert color
pressSequentially('jane.doe@'): one event per character neo-has-content, neo-invalid rgb(255, 138, 128), the invalid color

A pasted valid email keeps neo-empty-required too, but nothing shows it, because the alert rules nest under .neo-invalid.

The Problem

A field the user has just filled is styled as "required and still empty". Its error renders in the alert color instead of the invalid color, for anyone who pastes or autofills, which is how most emails get into a form. The class corrects itself only on the next input event, so typing hides the defect and paste exposes it.

The Architectural Reality

  • src/form/field/Text.mjs#afterSetInputValue toggles neo-empty-required from me.isEmpty() (:559). isEmpty() (:1435) reads value, and value is written at the end of the same method, by me.updateValueFromInputValue(value) (:565). The toggle therefore sees the value from before this input.
  • afterSetValue (:971) runs after every value change and already toggles neo-is-dirty there (:986), but not neo-empty-required. Nothing else toggles it: grep -n empty-required src/form/field finds only :559.
  • When the user types, each input event fixes the class the previous one left behind. One event (a paste, an autofill or fill()) leaves it wrong.
  • resources/css/src/form/field/Text.css nests &.neo-empty-required (:139) inside &.neo-invalid:not(.neo-disabled) (:114), and paints its .neo-textfield-error with --textfield-border-color-alert.

Design authority: useAlertState's JSDoc (Text.mjs:281): "Using the alert state will display an empty but required field in orange instead of red." A field with content in it is not empty.

The Fix

Toggle neo-empty-required in afterSetValue, beside neo-is-dirty, where isEmpty() reads the value it describes. Remove the toggle from afterSetInputValue. Every value change, typed or programmatic, then updates the class once, from the current value.

Acceptance Criteria

  • AC-1: A single input event that fills an empty required field (useAlertState: true) leaves no neo-empty-required in its cls. One more event that clears it sets the class again. Covered by a unit spec that is red on dev and green at head.
  • AC-2: In apps/form, fill('jane.doe@') in Work email and then Tab: the error text computes to the invalid color, not the alert color (outside-CI receipt on the PR, red on dev).
  • AC-3: The existing field unit specs (test/playwright/unit/form/field/) and test/playwright/e2e/form/FormApp.spec.mjs stay green.

Out of Scope

  • Changing required or useAlertState at runtime. The class follows at the next value change, as it does today.
  • The alert and invalid colors themselves (#21516).
  • PrefixField's reordered keystrokes (#21555).

Avoided Traps

  • Calling updateValueFromInputValue earlier in afterSetInputValue. That would run afterSetValue, and with it the change event, before afterSetInputValue has updated neo-has-content. Moving the toggle keeps one owner for value-derived classes.

Related

Parent #21329 (Forms & Fields at the Engine 14 cut) · #21516 / #21514 (neo-dark colors, whose AC-1 first saw this) · apps/form (#21336)

Ownership: Ada, for the Engine 14 lock on Sun 22 Nov under #21329, so not curated for contributors.

Live latest-open + closed sweep: the latest 20 open, plus open and closed searches ("required field alert state empty", "useAlertState OR neo-empty-required OR alert state required field"), at 2026-11-20T13:44Z and again at 13:49Z. No equivalent or prior exclusion. Backlog band: 53 open (red). This folds under the owning epic #21329. A2A: no claim on this scope among the latest 15, all read states. MC sweep: one symptom query ("required field shows the orange alert color instead of the red error after typing or pasting text"), 5 results, no prior decision. Own-assignment sweep: 4 open (#21559, #21329, #21049, #21041), none on this surface.

Origin Session ID: 523871d7-f228-44fc-bef7-f7720de4e0cd

Retrieval Hint: "required field neo-empty-required alert state lags one input event after paste or autofill, useAlertState"

⚖️ Ada · @neo-opus-ada · Claude Opus 5.5 · Claude Code

tobiu referenced in commit 099ce4c - "fix(form): the alert state follows the value after a paste (#21565) (#21567) on Nov 20, 2026, 4:04 PM
tobiu closed this issue on Nov 20, 2026, 4:04 PM