Skip to content

feat: replace option-like arrays via conditionals#263

Merged
danielcardoso5 merged 5 commits into
mainfrom
fix-options-deep-merging
Jul 8, 2026
Merged

feat: replace option-like arrays via conditionals#263
danielcardoso5 merged 5 commits into
mainfrom
fix-options-deep-merging

Conversation

@danielcardoso5

@danielcardoso5 danielcardoso5 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Matches v0 behavior by allowing to override option-like arrays present in oneOf / anyOf properties. This allows to change the list of options allowed for fields based on conditionals.

Example:

Schema

{
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "trigger": {
            "type": "string"
        },
        "choice": {
            "type": "string",
            "oneOf": [
                {
                    "const": "a",
                    "title": "A"
                },
                {
                    "const": "b",
                    "title": "B"
                },
                {
                    "const": "c",
                    "title": "C"
                }
            ]
        }
    },
    "allOf": [
        {
            "if": {
                "properties": {
                    "trigger": {
                        "const": "only c"
                    }
                },
                "required": [
                    "trigger"
                ]
            },
            "then": {
                "properties": {
                    "choice": {
                        "oneOf": [
                            {
                                "const": "c",
                                "title": "C"
                            }
                        ]
                    }
                }
            }
        }
    ]
}

Before After
image image

Note

Medium Risk
Changes core schema merge logic used when applying conditionals and updating fields; wrong array handling could break validation or option lists across many forms.

Overview
deepMergeSchemas now fully replaces schema arrays when a conditional branch supplies new values—except required, which still only appends missing entries. That replaces the old behavior that special-cased options and tried to merge array contents (including a buggy recursive merge on object items).

Conditional allOf / if / then merges can therefore narrow or swap field choices: oneOf, anyOf, enum, and presentation options update on validation and revert when the branch is inactive, with validation aligned to the active set.

Tests cover deepMergeSchemas edge cases, convertKBToMB, and headless-form scenarios for conditional oneOf, anyOf, and enum.

Reviewed by Cursor Bugbot for commit f06bb2a. Bugbot is set up for automated code reviews on this repo. Configure here.

@danielcardoso5 danielcardoso5 force-pushed the fix-options-deep-merging branch from 0e60932 to 2272b96 Compare July 3, 2026 17:44
@danielcardoso5 danielcardoso5 changed the title feat: replace enums and option-like arrays feat: replace option-like arrays via conditionals Jul 6, 2026
@danielcardoso5 danielcardoso5 marked this pull request as ready for review July 6, 2026 16:47
@danielcardoso5

Copy link
Copy Markdown
Collaborator Author

Internal pipeline is 🟢

Comment thread test/fields/options.test.ts Outdated
Comment thread src/utils.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d8dedad. Configure here.

Comment thread src/utils.ts
@danielcardoso5 danielcardoso5 force-pushed the fix-options-deep-merging branch from d8dedad to f06bb2a Compare July 8, 2026 08:57
@danielcardoso5 danielcardoso5 merged commit c20265e into main Jul 8, 2026
6 checks passed
@danielcardoso5 danielcardoso5 deleted the fix-options-deep-merging branch July 8, 2026 14:54
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.

3 participants