Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-218

Escape or a press outside closes a comment editor and asks before dropping a draft

When a reader presses Escape, wherever the focus is, or presses outside while the new comment box or the reply box of the thread popover is open, the page SHALL close it at once when its text is blank, and SHALL otherwise ask Discard or Keep editing inside the editor, without window.confirm, and drop the text only on Discard.

Part of StRS-MDOKFSTUDIO-REVIEW-003, outside the paths drawn on its map.

Scenarios 3

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

nominalEscape and a press outside close a blank editor
GivenWhenThen
an open new comment box with no text, or only spaces, and the focus anywherethe reader presses Escapethe box closes, nothing is sent and the event is stopped from reaching other handlers
the same boxthe reader presses the mouse or a pointer outside the box (not on the Comment button)the box closes and nothing is sent
an open thread popover whose reply box has no textthe reader presses Escape, or presses outside the popover and outside the highlightsthe popover closes
an open box or popoverthe reader presses inside itnothing is asked and nothing closes
nominalA changed draft is asked about, inside the editor
Givenan open new comment box, or a thread popover, whose text area holds text that is not blank
Whenthe reader presses Escape, wherever the focus is, or presses outside the editor
Thenthe editor stays open with its text, and a group named "Discard this comment?" (box) or "Discard this reply?" (popover) shows two buttons, Discard and Keep editing; in the box it replaces Save and Cancel
WHEN the reader presses Keep editing, THEN the question goes, the text stays and the text area has the focus
WHEN the reader presses Discard, THEN the editor closes and nothing is sent
`window.confirm` is never called
boundaryWhile the question shows
InputOutcome
Escapethe question goes and the editor stays open with its text, as Keep editing
another press outsidethe one question stays, no second one is added
the threads are posted again while the popover asksthe popover for the same thread asks again
the reader presses the highlight of the same thread, or of another thread, while the popover holds a changed draftthe popover asks and does not close or switch
Cancel in the new comment boxthe box closes without a question (Cancel is the explicit answer)

Implemented in 3

Tested by 2