Behaviour SwRS-MDOKFSTUDIO-FMEDIT-003
Enum, number, date, boolean and nullable fields use fitting controls
When a writer opens the editor of a schema enum, number, date, time, boolean or nullable field, the extension SHALL show the control that fits the type: a select offering the schema values for an enum, a native number, date or time input, a one-click toggle for a boolean and a Set to null button for a nullable field.
Another outcome at step 2 of path 1 in StRS-MDOKFSTUDIO-FMEDIT-001, in the state “A field editor is open”.
Scenarios 9
The situations the tests check; open one to read it.
nominalEnum fields show a select of the schema values
Givena schema enum field lifecycle with the values draft and active, currently draft
Whenthe writer opens its editor
Thenthe select holds the empty "Choose a value..." entry, draft and active, with draft selected; the entry is always the first option and Escape cancels
boundaryThe enum select and its commit
| Input | Outcome |
|---|---|
| Enum field whose current value is not one of the schema values | The disabled entry "Choose a value..." is selected and the select carries data-okf-empty-select true |
| active chosen, then the select loses focus | One previewFrontmatterSave with fieldValue "active" is posted |
| active chosen, then Enter pressed in the select | One previewFrontmatterSave with fieldValue "active" is posted |
| A value picked and nothing else happens | Nothing is posted: a pick alone does not save (there is no change listener on the select) |
| Value left unchanged | The editor closes without a post |
boundaryInput type per field type
| Input | Outcome |
|---|---|
| Schema number field | An input of type number with step any |
| Schema date field | An input of type date |
| Schema time field | An input of type time |
| Schema date-time field | A plain text input, not a date-time picker |
| Any other field type | A text input |
refusalAn invalid number is refused in the editor
| Input | Outcome |
|---|---|
| Number field editor with the input emptied, Enter pressed | The status reads "Enter a valid number." in the error state and no message is posted |
| Input that is not a finite number, Enter pressed | The same message and no post |
| Valid number typed, Enter pressed | The value is posted as a number |
| Navigation while the editor is open (a flush) | The typed text is sent instead, see SwRS-MDOKFSTUDIO-FMEDIT-067 |
| Number field without a schema, YAML box holding 3.5 and a line break, Cmd or Ctrl+Enter pressed | The YAML text is posted and the host writes rating: 3.5 |
| Same box holding text that is not a number | The same message and no post |
refusalSchema limits are left to the check at save time
Givena schema number field with minimum 0 and maximum 10
Whenits editor opens, and the writer saves the value 11
Thenthe input has no min or max attribute and accepts 11 (only step any is set), and the host refuses the save with a message starting "Schema validation failed: " (see SwRS-MDOKFSTUDIO-FMEDIT-016); the schema length and pattern limits are not applied to text controls either
nominalA boolean field toggles with one click
Givena schema boolean field set to true, edit mode on
Whenthe writer clicks its value cell
Thenone save with fieldValue false is posted and the checkbox uses the preview checkbox style
boundaryBoolean cells reached by other inputs
| Input | Outcome |
|---|---|
| Enter on the value cell of the boolean field | The checkbox opens, and its click or change saves |
| Click on the name cell of the boolean field | The key editor opens instead |
| Boolean field without a schema | The YAML editor opens, there is no one-click toggle |
nominalNullable fields offer Set to null
Givena nullable scalar field with its editor open
Whenthe writer presses "Set to null" (aria-label "Set {name} value to null")
Thena save with fieldValue null is posted
boundarySet to null on lists and on fields that are not nullable
| Input | Outcome |
|---|---|
| Nullable list field, editor opened | The button appears inside the list editor as a link-like button and saves null as well |
| Field that is not nullable | No such button |
Implemented in 1
Tested by 5
Known limits (3)
- date-time fields are edited as plain text.
- without a schema a boolean field opens the YAML editor, there is no one-click toggle.
- the schema minimum, maximum and pattern are not applied to the inputs and a required enum still shows the empty placeholder.
Replaces
SwRS-MDOKFSTUDIO-FMEDIT-007Number, date and time fields use native inputs superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-008An invalid number is refused in the editor superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-009A boolean field toggles with one click superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-017Nullable fields offer Set to null superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-050Editor controls do not apply the schema hints superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-074A chosen enum value is posted when the select loses focus or Enter is pressed superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-003 Markdown file