core
core copied to clipboard
[TASK] Style Editor API: Validate Default Values and Clarify Option Selection Behavior
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
- The API allows setting a
defaultValuethat 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'
}),
- When options are defined using
{ label, value }objects, and thedefaultValuematches 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' }
}),
- For
checkboxGroupfields, when nodefaultValueis 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
We remove "defaultValue" from the Style Editor schema, so this ticket is closed