Skip to content

Feat/short answer prefill progressive disclosure#9565

Draft
tutntut wants to merge 1 commit into
developfrom
feat/short-answer-prefill-progressive-disclosure
Draft

Feat/short answer prefill progressive disclosure#9565
tutntut wants to merge 1 commit into
developfrom
feat/short-answer-prefill-progressive-disclosure

Conversation

@tutntut

@tutntut tutntut commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #9356.

On the Short Answer field editor, both pre-fill controls — "Enable pre-fill" and "Prevent pre-fill editing" — are always shown ("Prevent pre-fill editing" merely greyed out when pre-fill is off). Pre-fill is an advanced feature used by a minority of admins on a very common field, so the always-visible controls clutter the editor and push the "Create field" button out of view.

Solution

Progressive disclosure: "Prevent pre-fill editing" is hidden until "Enable pre-fill" is on, matching the house pattern in EditEmail / EditMobile. The lock value is remembered while pre-fill is off (not reset), so re-enabling pre-fill restores the prior choice.

Alternatives considered

  • Remember the lock vs reset it (chosen: remember). Mirrors the Singpass authentication section, where "Collect NRIC/FIN/UENs" is hidden until authentication is enabled yet its value persists when auth is turned off. To match, the schema validator that rejected lockPrefill: true when allowPrefill: false was dropped. Safe because the lock only takes effect on the respondent side when a pre-fill value is present (isPrefillLocked = isPrefilled && lockPrefill).
  • A frontend invariant helper (an earlier cut extracted/tested enforcePrefillLockInvariant) became dead code under the remember model and was removed; persistence is now covered by the backend schema spec.

Changes

  • backend: remove the lockPrefill/allowPrefill cross-validator so the lock persists independently; update form_fields.schema.spec.ts.
  • frontend: render the lock toggle only when allowPrefill is on; remove the old ref/.click() reset workaround.
  • storybook: add a PrefillLocked story (pre-fill on, lock on).

Test plan

  • Backend schema spec passes, incl. new case: lockPrefill: true persists with allowPrefill: false.
  • Frontend tsc + ESLint clean.
  • Manual QA: toggle pre-fill off → on → confirm the lock choice is remembered; Field ID input + copy button unchanged; respondent side unaffected.

@tutntut tutntut force-pushed the feat/short-answer-prefill-progressive-disclosure branch 2 times, most recently from 89b81e1 to 8a1916e Compare June 8, 2026 13:40
Hide the "Prevent pre-fill editing" toggle until "Enable pre-fill" is on,
so the common case stays uncluttered and the "Create field" button stays
in view. Matches the disclosure pattern in EditEmail / EditMobile.

The lock value is remembered while pre-fill is off (not reset), mirroring
how the Singpass "Collect NRIC/FIN/UENs" setting persists when auth is
disabled. To allow this, drop the schema validator that rejected
lockPrefill without allowPrefill; it is safe because the lock only takes
effect on the respondent side when a pre-fill value is present.

- backend: remove the lockPrefill/allowPrefill cross-validator; update
  form_fields.schema.spec.ts to assert the lock persists independently
- frontend: render the lock toggle only when allowPrefill is on, and drive
  it via a Controller so it paints in its remembered state on mount with no
  on/off animation; remove the old ref/.click() reset workaround
- storybook: add a PrefillLocked story (pre-fill on, lock on)

Closes #9356

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tutntut tutntut force-pushed the feat/short-answer-prefill-progressive-disclosure branch from 8a1916e to 455e1d3 Compare June 8, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Progressive disclosure for Pre-fill feature

1 participant