Behaviour SwRS-MDOKFSTUDIO-BLOCK-109
The up and down arrows of an insert point move its block
While edit mode is on, the page SHALL give the insert point of every body block an up arrow labelled "Move the block above up" and a down arrow labelled "Move the block above down", and a click on an enabled arrow asks the host to swap the block with its neighbour; the page SHALL apply a previewBlockMoveResult only for the render it shows and ignore one that names another document, revision or request.
Step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-014: from “Edit mode is on” to “The host is asked to swap the block with its neighbour”.
Scenarios 12
The situations the tests check; open one to read it.
nominalEvery body bar holds the two arrows
Givena document with three body blocks in edit mode
Whenthe bars are built
the bar is the one under the last block of a block selection and the labels are updated
the bar is the one under the last block of a block selection and the labels are updated
Theneach bar holds a plus button, an up button and a down button with the labels above
they read "Move the selected blocks up" and "Move the selected blocks down" (see SwRS-MDOKFSTUDIO-BLOCK-156)
they read "Move the selected blocks up" and "Move the selected blocks down" (see SwRS-MDOKFSTUDIO-BLOCK-156)
boundaryThe arrows are disabled at the ends of the document
| Input | Outcome |
|---|---|
| Three body blocks | The up arrow of the first bar and the down arrow of the last bar are disabled, the others are enabled |
| One body block | Both arrows are disabled |
refusalThe properties bar and Start writing have no arrows
| Input | Outcome |
|---|---|
| A document with frontmatter in edit mode, the bar after the properties table | It holds only a plus button, a single control and no move buttons |
| An empty document, the Start writing bar | It holds only that button, a single control and no move buttons |
| A document with only frontmatter, the Start writing point | It holds a single control and no move buttons |
boundaryThe Delete block button follows the arrows
| Input | Outcome |
|---|---|
| The bar of a body block | A Delete block button sits right after the down arrow, touching it (SwRS-MDOKFSTUDIO-BLOCK-265) |
| The bar of an included block | No Delete block button |
| The move status of a refused move | It sits to the right of the Delete block button and never overlaps it |
boundaryThe arrows are hidden while a block editor is open
| Input | Outcome |
|---|---|
| A block editor is open | The move buttons and the Delete block button of all bars are not displayed |
| No editor is open | The arrows are displayed again |
nominalA click on an enabled arrow asks the host for the swap
Givena bar under a block at lines 7 to 8 and a neighbour at lines 10 to 12
Whenthe writer clicks the down arrow
ThenpreviewBlockMove carries line 7, endLine 8, neighbourLine 10, neighbourEndLine 12, direction down and pinViewportTop, one message per click
the bar is marked data-sphinx-move-pending until a refusal clears the mark or the re-render rebuilds the bars
the bar is marked data-sphinx-move-pending until a refusal clears the mark or the re-render rebuilds the bars
refusalA disabled arrow posts nothing and the arrows stand down during an edit
| Input | Outcome |
|---|---|
| A click on a disabled arrow at the end of the document | No message is posted |
| An arrow activated while a block editor or a field editor is open | No message is posted |
refusalA refused move says why next to the bar for six seconds
| Input | Outcome |
|---|---|
| The host answers ok false with a reason to a move requested from a bar | A status element with role status and the reason appears next to that bar and disappears after 6 s; the pending mark is cleared |
| The host answers ok true | No status is shown; the page is re-rendered |
nominalThe actions show on one block, the one that moved last
Givenedit mode, the pointer resting on a block and a keyboard block selection on another
Whenthe keyboard moves the selection (the page marks the root `data-sphinx-preview-actions-owner="keyboard"` and the bar under the last selected block `data-sphinx-actions-shown`)
the pointer then really moves (a move event at the same coordinates, such as the one a browser sends after a scroll, does not count)
the pointer then really moves (a move event at the same coordinates, such as the one a browser sends after a scroll, does not count)
Thenthe arrows and the plus of that bar are shown, those of the hovered block are not, and a click on an arrow acts on the block of the bar it is on
the owner is "pointer", the hovered block shows its actions again, the bar of the selection hides and the selection outline is removed
a selection that is cleared leaves the owner unset, so the hover alone shows the actions
the owner is "pointer", the hovered block shows its actions again, the bar of the selection hides and the selection outline is removed
a selection that is cleared leaves the owner unset, so the hover alone shows the actions
nominalA result for the render the page shows
Givena previewBlockMoveResult whose documentId, revision and requestId are those of the page's render
Whenit arrives
Thenit is handled, and a refusal reason is shown next to the insert point bar
refusalA result for another context
| Input | Outcome |
|---|---|
| a result whose requestId differs | ignored: no status is shown and no focus changes |
| a result that names another document | ignored |
| a result that names another revision | ignored |
boundaryA move refused as stale is sent once more
| Input | Outcome |
|---|---|
| A move whose result says "The preview is out of date. Try again once it has refreshed." | No message is shown; once the next render is in, the page sends the same move again from the blocks of that render |
| The second answer is the same refusal | The reason is shown next to the bar; the move is not sent a third time |
| No render arrives within five seconds | The reason is shown next to the bar |
Implemented in 6
Tested by 4
Replaces
SwRS-MDOKFSTUDIO-BLOCK-129The page applies a move result only for its own render superseded superseded by SwRS-MDOKFSTUDIO-BLOCK-109 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-064The insert point after the table has no move buttons superseded superseded by SwRS-MDOKFSTUDIO-BLOCK-109 Markdown file