Skip to content

feat: Collapse oneOf variants in a single text field - #591

Open
handreyrc wants to merge 3 commits into
open-workflow-specification:feature/node-editingfrom
handreyrc:collapse-string-only-one-of
Open

handreyrc wants to merge 3 commits into
open-workflow-specification:feature/node-editingfrom
handreyrc:collapse-string-only-one-of

Conversation

@handreyrc

Copy link
Copy Markdown
Contributor

Closes #397

This PR collapses oneOf variants in a single text field in the scenarios below:

# Field String alternatives Where to see it (Storybook)
1 Endpoint uri (*.endpoint.uri, with.server.uri) uriTemplate / runtimeExpression Nested Editing > Call Endpoint Union, callSecureApi: with.endpoint.uri
2 Event source (emit, listen) uriTemplate / runtimeExpression Examples > Emit, emitEvent: emit.event.with.source
3 Event dataschema uriTemplate / runtimeExpression Examples > Emit, emitEvent (optional field)
4 Event time string + date-time / runtimeExpression Examples > Emit, emitEvent (optional field)
5 raise.error.type uriTemplate / runtimeExpression Nested Editing > Raise Error Shapes, raiseByDefinition
6 raise.error.instance string + json-pointer / runtimeExpression Nested Editing > Raise Error Shapes, raiseByDefinition
7 raise.error.title runtimeExpression / string (any) Nested Editing > Raise Error Shapes, raiseByDefinition
8 raise.error.detail runtimeExpression / string (any) Nested Editing > Raise Error Shapes, raiseByDefinition
9 OAuth2 / OIDC authority uriTemplate only (two literal patterns), no expression Examples > Authentication OAuth2, getPet: ...oauth2.authority

Changes

  • Collapsed string-only oneOf/anyOf alternatives into a single text field in and its tooltip combines the descriptions when present.
  • Removed the hardcoded title lists in formatVariantLabel. URI and Expression labels are now derived from the schema (a URI format via the new isUriSchema, and the runtime-expression pattern). Error type and duration expressions now read URI/Expression too.
  • Merged string variants are also collapsed when mixed with non-string options in a picker. The merged option is named after its alternatives, with combined placeholders (URI example, ${...}, and a date-time example for format: date-time).
  • Replaced hasExpressionSibling on string fields with hasExpressionAlternative and a new caption property on StringField.
  • StringControl now styles the input as an expression while its live value matches the runtime-expression pattern. It links the caption through aria-describedby, and only blanks stale literals for expression-only fields.
  • FormField renders the new caption (dec-form-field-caption, styled in SidePanel.css, with dark mode), with a captionId helper in fieldHelpers.tsx.
  • Added useDeferredFieldValidation, used in TaskForm. It holds on-blur validation while a pointer is pressed, so an error appearing on blur can't shift the layout and make a click miss its target (add-field chips, drill rows, remove buttons). Keyboard blur still validates immediately.

How to test

  • Follow the column "Where to see it (Storybook)" in the table above to locate the changes in the form and compare against the latest code without the changes in this PR.

Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5bfaa2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@openworkflowspec/diagram-editor Minor
@openworkflowspec/core Minor
@openworkflowspec/i18n Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for openworkflow-editor ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5bfaa2d
🔍 Latest deploy log https://app.netlify.com/projects/openworkflow-editor/deploys/6b12d0abfa8ac1a5f99fb694
😎 Deploy Preview https://deploy-preview-591--openworkflow-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Nested union collapsing can hide saved URL and expression values, while runtime-expression schema detection can lose labels and disable expression styling; both issues need fixes and regression tests.

2 open issues
What changed in this PR

Simplifies schema-driven side-panel forms for issue #397 by combining string alternatives into one text input while retaining structural choices.

Changes:

  • Merges string alternatives with schema-derived labels, captions, placeholders, and expression styling.
  • Defers pointer-triggered blur validation to prevent layout shifts during clicks.
  • Updates unit, integration, and browser regression coverage.
File Description
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​validation/​useDeferredFieldValidation.test.ts Tests deferred validation and cleanup.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​taskFormContext.test.ts Updates merged-field sentinel expectations.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​TaskForm.oneOfLevels.test.tsx Tests simplified endpoint editing.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​TaskForm.eventFilters.test.tsx Adjusts filter option tests.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​TaskForm.customFields.test.tsx Tests moving text into merged fields.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​draft.test.ts Updates endpoint draft labels.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​forms/​customFields/​StringControl.test.tsx Tests live expression styling.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​EditFormFooter.variantRoundTrip.test.tsx Tests endpoint restoration across switches.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​EditFormFooter.reapply.test.tsx Updates merged endpoint selector.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​EditFormFooter.raiseTask.test.tsx Tests expression retention and accessible captions.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​EditFormFooter.draftStatus.test.tsx Updates variant round-trip coverage.
packages/​open-workflow-diagram-editor/​tests/​side-panel/​EditFormFooter.callHttpEndpoint.test.tsx Updates endpoint clear-and-apply tests.
packages/​open-workflow-diagram-editor/​tests/​fixtures/​taskValidation.ts Adds valid and invalid string-field cases.
packages/​open-workflow-diagram-editor/​tests/​core/​schemaToFormFields.test.ts Covers merging, labels, captions, and placeholders.
packages/​open-workflow-diagram-editor/​tests-e2e/​expression-clear-apply.spec.ts Uses the merged endpoint input.
packages/​open-workflow-diagram-editor/​tests-e2e/​add-field-after-error.spec.ts Tests clicks following invalid-field blur.
packages/​open-workflow-diagram-editor/​src/​side-panel/​SidePanel.css Styles captions in both themes.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​VariantPicker.tsx Generalizes an explanatory comment.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​validation/​useDeferredFieldValidation.ts Adds pointer-aware validation deferral.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​validation/​index.ts Exports the new hook.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​TaskForm.tsx Integrates deferred validation.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​FormField.tsx Renders string-field captions.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​customFields/​StringControl.tsx Adds dynamic styling and caption linkage.
packages/​open-workflow-diagram-editor/​src/​side-panel/​forms/​customFields/​fieldHelpers.tsx Adds caption ID generation.
packages/​open-workflow-diagram-editor/​src/​core/​schemaToFormFields.ts Merges string variants and derives presentation metadata.
.changeset/​collapse-string-only-one-of.md Records the minor release change.

Review effort: Balanced

Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
Signed-off-by: Handrey Cunha <handrey.cunha@gmail.com>
@handreyrc
handreyrc requested a review from lornakelly December 4, 2026 14:56

@lornakelly lornakelly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, LGTM

This branch has not been deployed

No deployments
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