core icon indicating copy to clipboard operation
core copied to clipboard

[TASK] Style Editor API: Validate Default Values and Clarify Option Selection Behavior

Open dario-daza opened this issue 11 months ago • 1 comments

Description

While performing QA on the Style Editor API, unclear behaviors were identified when configuring fields that contain options like the dropdown, radio buttons, and checkbox groups.

Currently

  1. The API allows setting a defaultValue that does not exist in the provided options, without throwing an error or warning.
styleEditorField.dropdown({
          label: 'Font Family',
          options: ["false", 'Helvetica', 'Times New Roman'],
          defaultValue: 'Arial Non Existing Value'
}),
  1. When options are defined using { label, value } objects, and the defaultValue matches both a label and a value across different options, the API behavior is ambiguous and undocumented.
styleEditorField.dropdown({
          label: 'Font Size',
          options: [
            { label: 'example', value: 'selected' }, // option with value set to 'selected'
            { label: 'selected', value: '12' }, // option with label set to 'selected'
            { label: '14', value: '14' }
          ],
          defaultValue: 'selected' // should be the option { label: 'example', value: 'selected' }
}),
  1. For checkboxGroup fields, when no defaultValue is provided, the expected behavior (all options defaulting to false) is not explicitly documented.
styleEditorField.checkboxGroup({
          label: 'Font Weight',
          options: ['Bold', 'Italic', 'Underline']
}),

Acceptance Criteria

  • [ ] When a field with options (dropdown, radio, checkboxGroup) defines a defaultValue that does not exist in the provided options, the API:

    • Throws a validation error or
    • Logs a clear warning indicating the default value is invalid.
  • [ ] When options are defined using { label, value } objects and the defaultValue matches both:

    • [ ] The option value must take precedence over the label.
    • [ ] This precedence rule (value over label) is documented clearly in the Style Editor API documentation.
  • [ ] For checkboxGroup fields:

    • [ ] If no defaultValue is provided, all options default to false.
    • [ ] The default behavior for checkboxGroup fields is explicitly documented.

Priority

Medium

Additional Context

No response

dario-daza avatar Dec 16 '25 18:12 dario-daza

We remove "defaultValue" from the Style Editor schema, so this ticket is closed

KevinDavilaDotCMS avatar Jan 31 '26 03:01 KevinDavilaDotCMS