Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-FMEDIT-019

A field editor saves a changed value and Escape cancels it

When a writer commits a field editor with Enter, with a checkbox change or by moving focus out of it, the extension SHALL post a save only when the value differs from the original, close the editor without a post on Escape, and show the progress and the outcome of the save in the editor.

Another outcome at step 2 of path 1 in StRS-MDOKFSTUDIO-FMEDIT-001, in the state “A field editor is open”.

Scenarios 12

The situations the tests check; open one to read it.

nominalA changed value is saved when the writer leaves the editor
Givena text field editor whose value was changed
Whenthe writer moves focus out of the editor
Thenone previewFrontmatterSave is posted; focus moving to the editor's own field menu or to Set to null does not save
boundaryAn unchanged value posts nothing
Givena field editor whose value is unchanged
Whenthe writer presses Enter or leaves the editor
Thenthe editor closes and nothing is posted
nominalA click on another field opens it after an unchanged editor closes
Givena field editor (value or key) whose value is unchanged, above other fields of the properties table
Whenthe writer clicks the value or key cell of another field, and closing the editor on the press moves that cell before the button is released
Thenthe editor closes without a post and the clicked field's editor opens in the same click; a click on a field above the editor does the same
refusalA press that is not completed by its click
InputOutcome
A press on a field cell released outside it (the click target does not contain the pressed cell) without an editor openNothing opens
A click that no press on a field cell, made while an editor was open, startedNothing opens
A press on a field cell with Shift, Ctrl, Alt or Cmd held, or with another buttonIt is not remembered; the click opens nothing from it
The writer clicks a field below an editor whose value was changedThe changed value is saved and no other editor opens in that click
nominalEscape cancels a field editor
Givena field editor with typed text
Whenthe writer presses Escape in the control, or in the field picker or a header cell of the properties section
Thenthe editor closes and nothing is posted
refusalEscape that does not cancel
InputOutcome
Escape outside the properties sectionThe editor stays open
Escape while the save of the editor is in flightThe editor stays open
boundaryTurning edit mode off closes a field editor without saving
Givena field editor with text typed and not saved
Whenthe writer turns edit mode off
Thenthe editor closes (closeFrontmatterEditor is called), the cell shows the original value again and no save is posted; an open block editor with unsaved changes is saved instead, which is the difference with a field editor
nominalA save in flight disables the editor and shows its status
InputOutcome
Field editor whose changed value was committed, host has not answeredThe controls are disabled and the status reads "Saving frontmatter…"
Key editor save postedThe status reads "Saving frontmatter key…"
Add field postedThe status reads "Adding frontmatter field..."
Remove field postedThe status reads "Removing frontmatter field..."
Host answers with saved trueThe status reads "Saved. Refreshing preview…", and the re-rendered table then replaces the editor
Result carrying another editIdIt is ignored and the status is unchanged
refusalA refused field save stays visible in the editor
InputOutcome
Host answers the posted save with an error messageThe message shows in the error state (red) in the editor, the controls are enabled and the editor stays open; Escape still closes it
The refusal arrives while the focus is on the page body or in the editor (the control was disabled during the save)The focus returns to the control with the caret at the end; the list editor focuses its first item
The refusal arrives after the writer moved the focus to another controlThe focus stays where the writer put it
The writer leaves the editor while it still holds the refused textNothing is posted again; the editor stays open with its message
The writer clicks another field's value or key cell (or presses Enter or Space on it) while the editor still holds the refused textThe refused editor closes without a save, the field shows its saved value, the refused text is discarded and the clicked field's editor opens in the same click
The writer changes the text after the refusal, then presses Enter or leaves the editorThe new text is saved once; a click on another field then saves it and opens no other editor in that click
Error result without textThe editor shows "The frontmatter edit could not be applied."
Result carrying another editIdIt is ignored
nominalUndo and redo keys act on the field text
Givena value editor with typed text
Whenthe writer presses Cmd or Ctrl+Z or Y
Thenthe key event stops at the control (keepUndoInControl calls stopPropagation) and the document is not undone; the same holds in a key editor, a list item and the custom key input
boundaryA save that changes no text closes the field editor with no message
Givena field editor whose value differs from the opening text but whose save plan leaves the document text unchanged
Whenthe writer leaves the editor
Thenthe host writes nothing and answers previewFrontmatterResult with saved and unchanged, and the page closes the field editor with no message
nominalEvery frontmatter save ends
Givena frontmatter save of a value, a key or a field action
Whenthe host handles it
Thenit answers with a saved result that closes the editor, or an error the editor shows; no frontmatter editor stays on its saving status

Implemented in 6

Tested by 10

Known limits (1)

Replaces

SwRS-MDOKFSTUDIO-FMEDIT-020Escape cancels a field editor superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-021Turning edit mode off closes a field editor without saving superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-022A save in flight disables the editor and shows Saving superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-023A refused field save stays visible in the editor superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-056Undo and redo keys in a field editor act on the field text superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-082An accepted field save shows that the preview is refreshing superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-019 Markdown file