Skip to content

feat(SurveyFormBuilder): lockable sections & questions#4512

Merged
sauldom102 merged 9 commits into
mainfrom
extract/survey-form-builder-blocked-questions
Jun 19, 2026
Merged

feat(SurveyFormBuilder): lockable sections & questions#4512
sauldom102 merged 9 commits into
mainfrom
extract/survey-form-builder-blocked-questions

Conversation

@sauldom102

@sauldom102 sauldom102 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds the ability to mark sections and individual questions in the SurveyFormBuilder as predefined and read-only. A locked item shows a lock affordance instead of its edit/drag controls, disables its inputs, and explains itself through a hover tooltip that falls back to a default notice from the F0Provider. This was extracted from the co-creation work in #4307, scoped down to just the survey changes.

Screenshots

Screenshot 2026-06-19 at 10 00 11

sauldom102 and others added 7 commits June 18, 2026 17:43
Extracted from #4307 — only the sds/surveys changes (blocked questions
and sections, locked tags, answering-form notices), plus the F0TagRaw
className prop and the surveyFormBuilder.labels.locked i18n key they
depend on.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…pe lock tooltip to the icon

QuestionNotice carried variant/title/icon (AlertVariant) but nothing
ever rendered it as an alert — only `description` is read, shown as a
title-less tooltip. Drop the unused fields.

Also move that tooltip off the whole question card onto just the lock
icon, so the explanation shows on hovering the lock rather than anywhere
on the question.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ce & LockedQuestionNotice

Make the lock-tooltip data model symmetric: a section carries a
LockedSectionNotice and a question carries a LockedQuestionNotice, both
{ description }, and the locked-question tooltip prefers the question's
own notice then falls back to the section's.

- rename QuestionNotice -> LockedSectionNotice (it lived on the section)
- type the question's lockedNote as LockedQuestionNotice (was a bare
  string) so both levels feed the popover the same way
- fix the answering-form test that set the section-only `notice` on a
  question; it now sets `lockedNote`

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Complete the lock-tooltip fallback chain: a locked question prefers its
own LockedQuestionNotice, falls back to the parent section's
LockedSectionNotice, and finally to a default lock notice that now lives
in the F0Provider i18n defaults (surveyFormBuilder.labels.lockedNotice)
instead of being hardcoded per story.

Stories migrated to the new model: lock explanations move from a
section's `description` to its `notice`, and the default-fallback story
drops the hardcoded text so it exercises the provider default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Questions could previously only be locked via a locked section. Add a
per-question `locked` flag so a standalone question can be locked on its
own, showing the lock affordance + tooltip and disabling its inputs.

The lock tooltip chain for a question is now: own `lockedNote` → parent
section's `notice` → default question notice. Split the provider default
into `lockedSectionNotice` (sections) and `lockedQuestionNotice`
(questions) to match the LockedSectionNotice / LockedQuestionNotice types.

Adds a "With Locked Questions" story (some questions carry their own
notice, others fall back to the default) and fixes the tooltip-on-hover
test to hover the lock icon rather than the whole card.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A standalone locked question isn't moved into place like a section's
members, so the default reads "edited or removed".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A read-only (locked/disabled) question with no description was still
rendering its textarea, showing an editable-looking placeholder. Gate it
on the same showDescription rule the section uses: render only when the
question is editable or actually has a description. Sections already
hide theirs when locked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sauldom102 sauldom102 requested a review from a team as a code owner June 19, 2026 07:59
@github-actions github-actions Bot added feat react Changes affect packages/react labels Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

✅ No New Circular Dependencies

No new circular dependencies detected. Current count: 0

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

🔍 Visual review for your branch is published 🔍

Here are the links to:

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

📦 Alpha Package Version Published

Use pnpm i github:factorialco/f0#npm/alpha-pr-4512 to install the package

Use pnpm i github:factorialco/f0#5831b3f82df7ad2eaf213b711fd63412a3ee351e to install this specific commit

A section and a question now use the same `lockedNote` field name for
their lock explanation (typed LockedSectionNotice / LockedQuestionNotice
respectively), instead of the section calling it `notice`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

⚠️ Breaking public API changes (3)

These public exports were renamed/removed, or had a property/parameter removed, retyped, or newly required compared to main — that breaks consumers. Adding new exports or new optional props is always safe and is not flagged. If a breaking change is intentional, note it in the PR description and use a feat!:/BREAKING CHANGE commit so the release is a major bump.

Comparing f0, experimental and ai against main. Adding components, types, or optional props is safe. This check is non-blocking.

🌐 Translations

  • ➕ Translation keys were added: surveyFormBuilder.labels.locked, surveyFormBuilder.labels.lockedQuestionNotice, surveyFormBuilder.labels.lockedSectionNotice

    The translations dictionary is embedded in many public exports (buildTranslations, defaultTranslations, i18n props, …), so its changes are summarized here once instead of being flagged on every export. Consumers maintaining full translation objects must update them.

f0

  • ✏️ F0AvatarModulePropsbreaking change

    • size union variants changed (6 → 5)
    before → after
    // before
    F0AvatarModuleProps
    // after
    F0AvatarModuleProps

experimental

  • ✏️ F0AvatarModulePropsbreaking change

    • size union variants changed (6 → 5)
    before → after
    // before
    F0AvatarModuleProps
    // after
    F0AvatarModuleProps
➕ Additive changes (safe) — 2
  • f0: LockedQuestionNotice, LockedSectionNotice

When a question shows no description (e.g. a locked question with none),
collapse the title-to-input gap from gap-4 to gap-2. Likewise, the first
question in a locked section sits closer to the section title, which has
no inline description beneath it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sauldom102 sauldom102 merged commit d38b29a into main Jun 19, 2026
15 checks passed
@sauldom102 sauldom102 deleted the extract/survey-form-builder-blocked-questions branch June 19, 2026 08:12
@eliseo-juan eliseo-juan mentioned this pull request Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 56.24% 17330 / 30809
🔵 Statements 55.42% 18048 / 32560
🔵 Functions 48.43% 3939 / 8133
🔵 Branches 49.17% 12375 / 25164
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/components/tags/F0TagRaw/F0TagRaw.tsx 100% 100% 100% 100%
packages/react/src/components/tags/F0TagRaw/types.ts 100% 100% 100% 100%
packages/react/src/lib/providers/i18n/i18n-provider-defaults.ts 100% 100% 100% 100%
packages/react/src/sds/surveys/SurveyAnsweringForm/SurveyAnsweringForm.tsx 74.39% 73.38% 60% 76.25% 126, 138, 141, 145-150, 167-177, 185, 207-212, 223, 473
packages/react/src/sds/surveys/SurveyAnsweringForm/types.ts 100% 100% 100% 100%
packages/react/src/sds/surveys/SurveyAnsweringForm/hooks/useSurveyFormSchema.tsx 49.21% 44.02% 47.36% 49.6% 41-45, 77-81, 96-138, 185, 188, 199-206, 272-323, 358-491, 527-575, 646-649, 676-701, 707
packages/react/src/sds/surveys/SurveyFormBuilder/types.ts 100% 100% 100% 100%
packages/react/src/sds/surveys/SurveyFormBuilder/Form/QuestionItem.tsx 64.7% 82.6% 25% 64.7% 39-40, 44-45, 89-90
packages/react/src/sds/surveys/SurveyFormBuilder/Form/SectionHeaderItem.tsx 57.14% 70.58% 20% 57.14% 32-33, 37-38, 77-90
packages/react/src/sds/surveys/SurveyFormBuilder/Form/index.tsx 96.92% 82.45% 100% 96.82% 82, 240
packages/react/src/sds/surveys/SurveyFormBuilder/Form/useReorderHandler.ts 73.58% 58.73% 78.57% 75.49% 64-69, 161, 164, 171-173, 182-218, 222-223
packages/react/src/sds/surveys/SurveyFormBuilder/Form/TableOfContent/useTableOfContentItems.ts 85.71% 83.67% 55% 85% 35-37, 78, 122, 130, 138, 175-183, 267-276
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/BaseQuestion/index.tsx 83.72% 88.09% 53.33% 83.33% 73-79, 85-91, 95-99, 103-106, 341, 377-393
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/BaseQuestion/types.ts 100% 100% 100% 100%
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/BaseQuestion/useQuestionDisabled.ts 100% 75% 100% 100%
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/BaseScoreQuestion/index.tsx 7.69% 0% 0% 7.69% 25-69
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/CheckboxQuestion/index.tsx 18.18% 0% 0% 18.18% 41-86
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/DateQuestion/index.tsx 14.28% 0% 0% 14.28% 26-49
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/DropdownSingleQuestion/index.tsx 60% 62.5% 20% 60% 33, 46-56, 85-96
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/FileQuestion/index.tsx 25% 0% 0% 27.27% 44-48, 61-90
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/LinkQuestion/index.tsx 12.5% 0% 0% 12.5% 26-53
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/NumericQuestion/index.tsx 12.5% 0% 0% 12.5% 27-71
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/SelectQuestion/index.tsx 1.72% 0% 0% 2% 26-205
packages/react/src/sds/surveys/SurveyFormBuilder/QuestionTypes/TextQuestion/index.tsx 88.88% 33.33% 66.66% 88.88% 70-73
packages/react/src/sds/surveys/SurveyFormBuilder/Section/index.tsx 78.57% 79.59% 33.33% 78.57% 52, 58-61, 65, 69, 73, 215
packages/react/src/sds/surveys/SurveyFormBuilder/Section/types.ts 100% 100% 100% 100%
packages/react/src/sds/surveys/SurveyFormBuilder/Section/Item/index.tsx 6.25% 0% 0% 6.25% 17-65
Generated in workflow #14902 for commit 85b8533 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changes feat react Changes affect packages/react

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant