Feat/short answer prefill progressive disclosure#9565
Draft
tutntut wants to merge 1 commit into
Draft
Conversation
89b81e1 to
8a1916e
Compare
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>
8a1916e to
455e1d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lockPrefill: truewhenallowPrefill: falsewas dropped. Safe because the lock only takes effect on the respondent side when a pre-fill value is present (isPrefillLocked = isPrefilled && lockPrefill).enforcePrefillLockInvariant) became dead code under the remember model and was removed; persistence is now covered by the backend schema spec.Changes
lockPrefill/allowPrefillcross-validator so the lock persists independently; updateform_fields.schema.spec.ts.allowPrefillis on; remove the old ref/.click()reset workaround.PrefillLockedstory (pre-fill on, lock on).Test plan
lockPrefill: truepersists withallowPrefill: false.tsc+ ESLint clean.