Try: Block controls rendering by block's edit
#830
Merged
+36
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request explores an option to render a block's controls in its
edit
implementation.Benefits:
controls
callbacks have no access to theedit
component instance, so in the case of proper component classes, they cannot make use of component stateedit
isActive
andonClick
callbacks, since it's easy enough to bind useattributes
andsetAttributes
from the bound component instance or rendering scope.Downsides:
focus
to ensure controls are only rendered if the block is currently selectedFor related discussion, see also #717 (comment).
Open questions:
<BlockControls />
as an additional layer when the block implementer could as easily render the<Fill />
directly?Formatting.Controls
slot, do we care to make this the preferred approach if we could support both just the same? Could be nice to consolidate, but only if it's not viewed as more complex.uid
fromVisualEditorBlock
toBlockControls
directly, bypassing the need for the block implementer to concern themselves with whether the block is currently selected, at the cost of reducing transparencyTesting instructions:
Ensure that heading block controls are shown and behave the same as in master. Only the heading block has been ported in this demonstration.