Skip to content

Nested Section Child Required Logic Does Not Update #154

Description

@lattln
Image

Problem Statement

When a response field nested inside a section is selected and its Logic Editor Required control is changed, the change is applied to the parent section instead of the nested child field.

Sections can be required. This ticket does not change section-required behavior. It fixes the Logic Editor update target when editing a child within a selected section.

Root Cause

EditPanel correctly resolves the nested child as logicField when a section and child are selected. However, onUpdateDef uses handleUpdate, which calls selectedField_.update(patch). selectedField_ is bound to selectedFieldId, the parent section.

For a root field, selectedFieldId and logicField.definition.id are the same, so the control works. For a nested child, they differ, so the parent section receives the Required patch.

Proposed Solution

Bind the Logic Editor update callback to logicField.definition.id rather than the selected parent field. Retain the existing selected-field callback for the Edit tab, which edits the selected field itself.

Implementation Checklist

  • Update packages/builder/src/lib/components/edit-panel/EditPanel.tsx so Logic Editor definition patches target logicField.definition.id.
  • Preserve the existing Edit tab updates and field-renaming behavior for the selected field.
  • Add a builder regression test for setting Required on a nested child inside a section.
  • Verify the test asserts the child changes and the parent section remains unchanged.
  • Verify Required still works for root-level fields.
  • Run the affected builder Vitest suite and pnpm format:check.

Technical Considerations

  • Core updateField(fieldId, patch) supports nested field IDs, so no core validation or renderer changes are required.
  • Do not hide Required for sections or remove sections from NON_INPUT_TYPES; that was based on an incorrect interpretation of the reported issue.
  • The issue affects other Logic Editor definition updates routed through onUpdateDef, not only the Required segmented control. The regression test should exercise the callback path generally where practical.

Success Criteria

  • Changing Required for a nested child updates that child definition.
  • The parent section definition is unchanged.
  • Required behavior remains unchanged for sections and root-level response fields.
  • Automated coverage prevents a parent/child callback binding regression.

Related Files

  • packages/builder/src/lib/components/edit-panel/EditPanel.tsx
  • packages/builder/src/lib/components/edit-panel/LogicEditor.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions