-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Labels
BugSomething isn't workingSomething isn't working
Milestone
Description
Bug Description
Page Attachment can be copied to a Page where CTA already exists.
Expected Behaviour
Each Page can only have exactly 0 or 1 unmovable block. If either a CTA block or a Page Attachment block already exists on a Page then it should not be possible to Paste another unmovable block to that Page.
- The Paste option should not appear in the context menu if Pasting the block is forbidden.
- PasteHandler should consider Page Attachment block as well and prevent Pasting, currently, it does have a
casebut it does not handle it properly:
case 'amp/amp-story-page-attachment': case 'amp/amp-story-cta': const currentBlock = getPageBlockByName( clientId, block.name ); if ( currentBlock || ( isFirstPage && block.name === 'amp/amp-story-cta' ) ) { return; } allowedBlocks.push( block ); break;
Steps to reproduce
- Add 2 Pages
- Add Page Attachment to the first Page
- Add CTA block to the second Page
- Right-click on the Page Attachment and choose "Copy" from the context menu
- Right-click on the second Page and choose "Paste" from the context menu.
- See both CTA block and Page Attachment block on the second Page.
Screenshots
Additional context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- When pasting, page attachment blocks should not be inserted when there already is another page attachment block on the page.
- When pasting, page attachment blocks should not be inserted when there already is a CTA block on the page.
- When pasting, CTA blocks should not be inserted when there already is another CTA block on the page.
- When pasting, CTA blocks should not be inserted when there already is a page attachment block on the page.
Implementation brief
-
Replace usage of
ensureAllowedBlocksOnPastewithisBlockAllowedOnPagehook, as this check is more robust. -
Remove all references to
ensureAllowedBlocksOnPaste. -
Check a block can not be pasted, display a 'snap' message to inform user the block could not be pasted.
QA testing instructions
- Add 2 Pages
- Add Page Attachment to the first Page
- Add CTA block to the second Page
- Right-click on the Page Attachment and choose "Copy" from the context menu
- Right-click on the second Page and choose "Paste" from the context menu.
- Verify that Page Attachment is not allowed on the second page and a snackbar with a notice appears.
Repeat with CTA block copied to page with Page Attachment and vice-versa.
Repeat with pasting via keyboard.
Demo
Changelog entry
- Prevent pasting CTA or Page Attachment blocks when one already exists.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working
