Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

Fixes: #10679

This PR adds a flag that allows a block to opt-out being converted into a reusable block as discussed in #10679.

This new logic is used to disable the conversion of column block into a reusable block and to simplify existing logic that disables classic and missing block conversion to reusable blocks.

These simplifications add a behavior change.
Before it was not possible to convert classic or missing block into a reusable block, but if another block was selected with it (even an empty paragraph) it was possible to convert that blocks into reusable blocks, now that's not the case.
If a block that is part of the selection cannot be converted into a reusable block, the option to convert the selected blocks into a reusable block will not be shown.
I think that is the desired behavior.

How has this been tested?

Verify it is not possible to convert to reusable blocks, the "Column" block, the classic block or an invalid block.
Verify it is still possible to convert to reusable blocks the "Columns" block.
Test complex scenarios e.g. multiple selections of Columns and a paragraph, and verify the conversion is possible.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. [Feature] Blocks Overall functionality of blocks [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) labels Nov 6, 2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit but these should all be one line, no line breaks :)

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small non-code details to fix up, but code looks / works great 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment now only really covers part of what's being done with the every condition. We might want to enhance it slightly, or even move it to cover the specific parts of the predicate for which it is relevant (!! block && block.isValid, with complementing comment for the hasBlockSupport check).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we formalize this on the blocks API rather than ad hoc exemptions 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is missing a sentence stop between "block" and "if"

@jorgefilipecosta jorgefilipecosta force-pushed the add/flag-that-allows-disable-of-the-converstion-to-reusable-blocks branch from 9e127e0 to e5325fc Compare November 7, 2018 09:54
@jorgefilipecosta jorgefilipecosta merged commit 7c63d10 into master Nov 7, 2018
@jorgefilipecosta jorgefilipecosta deleted the add/flag-that-allows-disable-of-the-converstion-to-reusable-blocks branch November 7, 2018 12:01
@jorgefilipecosta jorgefilipecosta added this to the 4.3 milestone Nov 7, 2018
daniloercoli added a commit that referenced this pull request Nov 7, 2018
…rnmobile/fix-merge-content-not-refreshed-UI

* 'master' of https://github.com/WordPress/gutenberg:
  Fix the isBeingScheduled Selector.  (#11572)
  Slot/Fill pattern with Toolbar #199 (#11115)
  Add mechanism to avoid forced child selection on blocks with templates. (#10696)
  Allow a block to disable being converted into a reusable block; Fix: Column block (#11550)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Block API API that allows to express the block paradigm. [Feature] Blocks Overall functionality of blocks [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants