Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-004

Arrow keys, Enter and Escape drive block editing without the mouse

When edit mode is on and no editor is open, the page SHALL move a one-block selection with ArrowUp and ArrowDown, open the selected block with Enter, and, when an editor closes through Escape or Cmd/Ctrl+Enter, leave the edited block selected; the keys SHALL work while the page itself holds the focus, and a window or tab that comes back SHALL restore the selection.

Part of StRS-MDOKFSTUDIO-BLOCK-008, outside the paths drawn on its map.

Scenarios 5

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

nominalUp and Down select, Enter opens, Escape or Cmd/Ctrl+Enter returns to the selection
Givenedit mode on, no editor open and no block selected
Whenthe writer presses ArrowDown, ArrowDown, Enter, types, then presses Escape (or Cmd/Ctrl+Enter)
Thenthe first press selects the body block nearest the top of the viewport, the second moves the selection to the next block, Enter opens the editor of the selected block, and Escape cancels (Cmd/Ctrl+Enter saves) and leaves that block selected, so the next ArrowUp or ArrowDown carries on from it

The selection is the one of SwRS-MDOKFSTUDIO-BLOCK-140: it is outlined in the focus colour, scrolled into view, takes the focus and is announced as "1 block selected". After a save, the block is selected once the patch of the save is in; when the save changed the number of blocks, nothing is selected.

boundaryMoving the selection
InputOutcome
ArrowDown on the last block, ArrowUp on the firstThe selection stays
ArrowUp or ArrowDown with a run of blocks selectedThe run collapses onto the neighbour of its free end
A neighbour that comes from an includeIt is skipped
Enter with no selectionNothing opens
Enter on the page itself (the focus lost to the body) with a selectionThe editor of the free end of the selection opens
Delete or Backspace with a block selectionThe selected blocks are deleted (SwRS-MDOKFSTUDIO-BLOCK-265)
Delete or Backspace with only a focused block, a focused bar button, a text box, an open editor, or the structural cursor on a cell, a list item or an inner blockNothing is deleted
nominalComing back to the window
Givenedit mode on, no editor open, and the page itself holds the focus (the writer clicked the margin of the page, or the window or the tab comes back)
Whenthe writer presses ArrowDown
Thenthe selection moves as above and the page shows no focus ring; when the window or tab comes back, the block that was selected (else the last one the keyboard selected, else the block nearest the top of the viewport) is selected again and holds the focus before any key is pressed
refusalKeys that belong to other controls
InputOutcome
ArrowUp, ArrowDown or Enter with edit mode offNothing is selected or opened
ArrowDown in a block editor text box, a field or the properties tableThe key stays with that control
ArrowDown with Shift, Alt, Ctrl or CmdNot handled here: Shift extends a run (BLOCK-140), Alt moves the block
ArrowDown on the edit-mode toggle right after it was pressedHandled as on the page
The window comes back with a toolbar button, a block or an editor focused, or outside edit modeThe selection is left as it is

Table-cell editors keep their own Escape and Cmd/Ctrl+Enter and do not select a block when they close.

nominalThe arrows reach each blank-line block
Givenedit mode on and two blank-line blocks between two blocks
Whenthe writer presses Down on the block above, and then Down again
Thenthe first blank-line block is selected, then the second, and the next Down selects the block below them (see SwRS-MDOKFSTUDIO-BLOCK-267)

Implemented in 1

Tested by 5