LearnNewsExamplesServices
Frontmatter
id18737
titleA server-reported document deletion leaves the file field styled as non-empty
stateClosed
labels
bugai
assigneesneo-opus-vega
createdAtSep 15, 2026, 3:38 PM
updatedAtSep 15, 2026, 5:56 PM
githubUrlhttps://github.com/neomjs/neo/issues/18737
authorneo-opus-vega
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 15, 2026, 5:56 PM

A server-reported document deletion leaves the file field styled as non-empty

neo-opus-vega
neo-opus-vega commented on Sep 15, 2026, 3:38 PM

[!IMPORTANT] Corrected by the author before implementation — see the correction comment. The "reachable consequence" section below is wrong: on the server-deletion path me.document is still set, so the intended behaviour there is to remove neo-field-empty, which is already its state. file/document become falsy in exactly one place — clear() — and clear() adds the class itself. The dead line is therefore LATENT, not live. The defect and the fix stand; the user-visible-today claim does not. ACs updated accordingly.

Context

Found while enumerating this.cls swap sites for #18736. form/field/FileUpload.mjs#afterSetState was excluded from that migration because it combines a swap with an independent toggle — and reading it closely showed the toggle half never executes.

The Problem

afterSetState intends to keep neo-field-empty in sync with whether the field actually holds something. The line meant to do it is dead code:

NeoArray[me.file || me.document ? 'remove' : 'add', 'neo-field-empty'];

That is a comma expression inside a computed member access. It evaluates me.file || me.document ? 'remove' : 'add', discards it, yields 'neo-field-empty', and resolves to NeoArray['neo-field-empty'] — undefined. No call is made, no argument is passed, nothing throws. The statement has no effect whatsoever.

The intended form is a call, taking cls:

NeoArray[me.file || me.document ? 'remove' : 'add'](cls, 'neo-field-empty');

The Architectural Reality

neo-field-empty is the component's own default (cls: ['neo-field-empty']) and three style rules key on it — resources/scss/src/form/field/FileUpload.scss:103 (&:not(.neo-field-empty)), :109 (&.neo-field-empty), :128 (&.neo-invalid:not(.neo-field-empty)). So the class is load-bearing for appearance, not decorative.

Every other site manages it correctly, and between them they cover the common paths — which is why this has stayed invisible:

site what it does
clear() (:410) adds it — the user-initiated clear path works
onInputValueChange() (:440) removes it when files arrive
afterSetDocument() (:696) removes it when a document arrives
afterSetState() (:777) intended to re-sync it — does nothing

So two paths remove it, one adds it, and the general re-sync is dead. Nothing restores the class outside clear().

The reachable consequence

checkDocumentStatus() handles the server reporting the document gone:

case 'deleted':
    me.error = `${me.documentText} ${me.documentId} ${isNoLongerAvailable}`;
    me.state = 'ready';
    break;

It sets state back to ready but does not clear me.document and does not touch cls. afterSetState is therefore the only thing that could re-add neo-field-empty — and it cannot. The field returns to its ready state while still rendering as though it holds a document, against all three SCSS rules. The 'error' → state = 'deleted' branch reaches the same gap.

The Fix

Repair the statement in place, keeping the existing aggregate block so the method stays at one cls assignment and therefore one vdom update. util.Array#toggle expresses the intent directly and takes the enforcing boolean:

NeoArray.toggle(cls, 'neo-field-empty', !me.file && !me.document);

toggle(arr, item, add = !this.hasItem(arr, item)) — passing add explicitly makes it a sync rather than a flip, which is what this path needs.

Do not split this into removeAddCls() + toggleCls(). Each assigns cls separately, so the method would go from one vdom update to three. This site is the reason #18736's new removeAddCls deliberately does not try to express combinations of class operations — where a swap and an independent toggle occur together, the aggregate read-mutate-assign form is correct and stays.

Decision Record impact

none. A dead statement is repaired; no contract, config shape or update-pipeline behaviour changes.

Acceptance Criteria

  • The dead NeoArray[...] member-access statement in afterSetState is replaced by an executing call.
  • After state changes, neo-field-empty is present exactly when the field holds neither file nor document, and absent otherwise.
  • A unit arm covers the server-deletion path: with document set and state moved to ready, the class is present — this arm must fail against current dev, which is what distinguishes a repair from a restatement.
  • afterSetState still performs exactly one cls assignment; an update-count arm asserts one update per state change, not merely the resulting class set.
  • clear(), onInputValueChange() and afterSetDocument() are unchanged and still reach their existing class outcomes.
  • The neo-file-upload-state-* swap in the same method is unchanged in behaviour.

Out of Scope

  • Migrating this method to removeAddCls() / toggleCls() — see The Fix; it would cost two extra updates.
  • Whether checkDocumentStatus() should also clear me.document on a server-reported deletion. It plausibly should, and that is a separate behavioural question about ownership of the document reference; this ticket only makes the class follow whatever file/document actually are.
  • The three SCSS rules, and the rest of #18736's migration.

Avoided Traps

NeoArray[cond ? 'a' : 'b', 'x'] is valid JavaScript. It parses, runs, throws nothing, and lints clean — the comma operator is legal inside a computed member access. Nothing in CI can see it. The tell is the absence of the cls argument: every sibling call in the file passes the array first.

A class-set assertion after clear() will pass either way. clear() adds the class itself, so a test routed through it cannot detect the dead line. The arm must drive the server-deletion path, which is the one with no other writer.

Do not "fix" it by adding a second assignment. The obvious spelling — appending me.toggleCls(...) after the existing block — works and triples the update cost. The repair belongs inside the existing aggregate block.

Related

  • #18736 — the removeAddCls lane that surfaced this; this method is its documented exclusion, and the reason the new helper does not cover combinations.
  • resources/scss/src/form/field/FileUpload.scss:103,109,128 — the rules that key on the class.

Sweeps. Exact-search on neo-field-empty and on FileUpload state/empty wording: no open or closed equivalent. Live latest-open checked 2026-09-15 (#18736, #18731, #18680 newest) — no overlap. A2A in-flight claim sweep: no claim on form/field/FileUpload.mjs. Own-assignment sweep: #18736, #18532, #18064, #17918, #16358, #16212, #15202 — none covers this.

Origin Session ID: a2868f57-a008-4abf-b493-b87be1636964

Retrieval Hint: FileUpload neo-field-empty dead comma expression computed member access state sync

tobiu referenced in commit 97ee4cd - "The empty-state class follows the field's contents, instead of a statement that never ran (#18737) (#18739) on Sep 15, 2026, 5:56 PM
tobiu closed this issue on Sep 15, 2026, 5:56 PM