Skip to content

When Pasting an Item it does not Always Paste on the Top Layer #3430

@MackenzieHartung

Description

@MackenzieHartung

Bug Description

When a user goes to paste an item, upon the paste action the item does not always paste on the top layer.

Expected Behaviour

Pasted item would always be the top layer when pasted.

Steps to reproduce

  1. Copy a block
  2. Paste a block

Screenshots

Screen Shot 2019-10-03 at 6 32 16 AM

Screen Shot 2019-10-03 at 6 32 29 AM

Screen Shot 2019-10-03 at 6 32 34 AM

Additional context

  • WordPress version:
  • Plugin version: 1.3-rc
  • Gutenberg plugin version (if applicable):
  • AMP plugin template mode:
  • PHP version:
  • OS:
  • Browser: [e.g. chrome, safari]
  • Device: [e.g. iPhone6]

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Pasted blocks should be on the top most layer of the page, i.e. in the block navigation it would appear at the top, not the bottom.

Implementation brief

Blocks are inserted when pasting in two places:

insertBlocks( ensureAllowedBlocksOnPaste( content, pageClientId, isFirstPage ), null, pageClientId ).then( ( { blocks } ) => {

and

insertBlocks( ensureAllowedBlocksOnPaste( content, clientId, isFirstPage ), null, clientId );

In both cases, the index where to set the block is currently set to null. We should replace that with an appropriate index to ensure that the block is pasted to the last position.

QA testing instructions

Using context menu

  • Add an image to a story.
  • Right click the image and select "cut".
  • Add a text block to the same page.
  • Right click the page just above the text block and select "paste".
  • Verify that the image is pasted on top of the text block, not below.

Using keyboard

  • Add an image to a story.
  • Make sure the image has focus.
  • Press ctrl-x/cmd-x to cut the image from the page.
  • Add a text block to the same page.
  • Make sure the page has focus.
  • Press ctrl-v/cmd-v to paste the image to the page.
  • Verify that the image is pasted on top of the text block, not below.

Demo

Changelog entry

  • Changed behavior so that pasted elements are always inserted at the top

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions