Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: WordPress/gutenberg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3b127a7a05da06546f2173ed0312df9c105a0a74
Choose a base ref
..
head repository: WordPress/gutenberg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 583d6fb76b53d40c89fad08fc7814944d8d3a56a
Choose a head ref
40 changes: 15 additions & 25 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import { useViewportMatch, useMergeRefs } from '@wordpress/compose';
import { forwardRef, useRef } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { getBlockType, withBlockContentContext } from '@wordpress/blocks';
import { applyFilters } from '@wordpress/hooks';

/**
* Internal dependencies
@@ -50,32 +49,9 @@ function UncontrolledInnerBlocks( props ) {
__experimentalLayout,
} = props;

const context = useSelect(
( select ) => {
const block = select( blockEditorStore ).getBlock( clientId );
const blockType = getBlockType( block.name );

if ( ! blockType || ! blockType.providesContext ) {
return;
}

return getBlockContext( block.attributes, blockType );
},
[ clientId ]
);

const FilteredAllowedBlocks = useSelect( ( select ) => {
const block = select( blockEditorStore ).getBlock( clientId );
const blockFilterName = block.name.replace( '/', '-' );
return applyFilters(
`editor.InnerBlocks.${ blockFilterName }.allowedBlocks`,
allowedBlocks
);
} );

useNestedSettingsUpdate(
clientId,
FilteredAllowedBlocks,
allowedBlocks,
templateLock,
captureToolbars,
orientation
@@ -88,6 +64,20 @@ function UncontrolledInnerBlocks( props ) {
templateInsertUpdatesSelection
);

const context = useSelect(
( select ) => {
const block = select( blockEditorStore ).getBlock( clientId );
const blockType = getBlockType( block.name );

if ( ! blockType || ! blockType.providesContext ) {
return;
}

return getBlockContext( block.attributes, blockType );
},
[ clientId ]
);

// This component needs to always be synchronous as it's the one changing
// the async mode depending on the block selection.
return (
4 changes: 4 additions & 0 deletions packages/block-library/src/social-links/block.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@
"name": "core/social-links",
"category": "widgets",
"attributes": {
"allowedBlocks": {
"type": "array",
"default": [ "core/social-link" ]
},
"iconColor": {
"type": "string"
},
5 changes: 2 additions & 3 deletions packages/block-library/src/social-links/edit.js
Original file line number Diff line number Diff line change
@@ -31,8 +31,6 @@ import {
import { __ } from '@wordpress/i18n';
import { check } from '@wordpress/icons';

const ALLOWED_BLOCKS = [ 'core/social-link' ];

const sizeOptions = [
{ name: __( 'Small' ), value: 'has-small-icon-size' },
{ name: __( 'Normal' ), value: 'has-normal-icon-size' },
@@ -51,6 +49,7 @@ export function SocialLinksEdit( props ) {
} = props;

const {
allowedBlocks,
iconBackgroundColorValue,
iconColorValue,
itemsJustification,
@@ -93,7 +92,7 @@ export function SocialLinksEdit( props ) {

const blockProps = useBlockProps( { className } );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: ALLOWED_BLOCKS,
allowedBlocks,
orientation: 'horizontal',
placeholder: SocialPlaceholder,
templateLock: false,