ReviewOS

stacks/stx

fix(native): preserve interactive label children and translate input types correctly

#2087
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Problem

Native translation can remove shared controls or emit the wrong control type.

Audited at v0.2.546, commit 0013ce66e3.

Reproduced evidence

  • Compiling the shared-library Switch produces text in place of its label subtree; its interactive button is gone.
  • <label>Agree<input type="checkbox" /></label> translates to a single Text node containing "Agree", with a flattened-text diagnostic.
  • Each of <input type="checkbox" />, <input type="radio" />, and <input type="hidden" /> translates to TextInput, with no diagnostic.

Sources:

Requested change

Translate controls based on their HTML semantics, preserve interactive descendants inside labels/text containers, and keep hidden form values from becoming visible text inputs. Define a supported native radio representation or report unsupported behavior explicitly.

Acceptance

  • Shared Switch retains a usable control and responds to changes.
  • Checkbox produces the intended checkbox semantics and checked state.
  • Radio grouping/selection is supported or clearly diagnosed.
  • Hidden inputs do not render visible controls.
  • Label text and its control both survive translation.
  • Regression coverage compiles the real shared-library templates and checks native node types plus interactions.
  • Ordinary inline text remains correct.

Priority

Second in the portability audit sequence. Translation fixes can proceed independently; complete interaction tests also depend on the reactive-props/events issue. Compiler output was verified; device rendering was not exercised in this audit.

8 days ago

Fixed on main in eaa734e. Version: this follows v0.2.582 and is not yet in a numbered release.

Labels retain interactive children; the actual shared Switch and Checkbox survive translation and respond to native events and parent resets. HTML checkbox checked state is separate from its form value. Hidden inputs retain metadata without rendering text fields. Radio interaction remains unsupported and now produces an explicit unsupported-control diagnostic, as permitted by this issue acceptance criteria.

Regression tests: packages/stx/test/native/html-to-ir.test.ts and shared-component-props.test.ts. The native/model/runtime-parse verification passed 462 tests. CI on 36a98d2 is green: https://github.com/stacksjs/stx/actions/runs/39264397388

Validation covers compiler output and native bridge interactions; device rendering was not exercised. Form collection/submission remains tracked separately in #2088.

Sign in to comment on this issue.