Skip to content

@dashforge/tw: dev warning for standalone form widget without value/onChange (G-29) #113

Description

@kensaadi

Symptom

When a @dashforge/tw form widget (TextField, NumberField, Textarea, Switch, Checkbox, RadioGroup, Select) is rendered:

  • Outside a DashFormProvider (so useContext(DashFormContext) === undefined and isFormMode === false)
  • AND without value + onChange props

... the component silently renders as an uncontrolled input that never emits changes. No error, no warning, no visual hint — the input just doesn't work. Extremely hard to diagnose.

Context

Filed in Blueprint's dogfood report as G-29, added 2026-07-08 alongside the G-26 reclassification. Runtime verification confirmed that @dashforge/tw form widgets DO work as standalone controlled inputs (via InputHTMLAttributes<HTMLInputElement> inheritance) when value + onChange are provided. The problem is the failure mode when a consumer forgets BOTH the provider AND the controlled props.

Why this is worth fixing

  • Silent no-op is the worst possible failure mode — no signal that the widget is broken
  • Very common consumer mistake: mounting <TextField> in a shell that isn't a form and forgetting to add value + onChange
  • Cheap fix: single dev-only warning in a shared helper, no runtime cost in production

Acceptance

  • Shared helper detects the condition (!isFormMode && userValue === undefined && userOnChange === undefined) once per widget mount
  • console.warn in dev mode only (guard on process.env.NODE_ENV !== 'production') — silent in prod
  • Warning message: "[@dashforge/tw] <TextField name=\"X\"> is not inside a DashFormProvider and no value/onChange were provided. Did you forget the provider, or intend controlled mode? See docs on controlled vs bridge mode."
  • Same helper applied to all form widgets (TextField, NumberField, Textarea, Switch, Checkbox, RadioGroup, Select)
  • Docs page in dashforge-docs-lab documents "controlled vs bridge mode" explicitly so the warning message links somewhere useful

Related

  • Adjacent to (but does NOT depend on) the G-26 reclassification in Blueprint's dogfood report — the widgets already work standalone; this is a paper-cut fix on top of that discovery

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpackage:twAffects @dashforge/tw package

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions