Skip to content

Commit

Permalink
Fix alligned blocks (#32454)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Jun 7, 2021
1 parent 4c3300c commit 108da99
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function BlockListBlock( {
clientId,
className,
wrapperProps: omit( wrapperProps, [ 'data-align' ] ),
isAligned,
};
const memoizedValue = useMemo( () => value, Object.values( value ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const BLOCK_ANIMATION_THRESHOLD = 200;
* @return {Object} Props to pass to the element to mark as a block.
*/
export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
const { clientId, className, wrapperProps = {} } = useContext(
const { clientId, className, wrapperProps = {}, isAligned } = useContext(
BlockListBlockContext
);
const {
Expand Down Expand Up @@ -141,7 +141,9 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
'data-title': blockTitle,
className: classnames(
// The wp-block className is important for editor styles.
'wp-block block-editor-block-list__block',
classnames( 'block-editor-block-list__block', {
'wp-block': ! isAligned,
} ),
className,
props.className,
wrapperProps.className,
Expand Down
4 changes: 1 addition & 3 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Consider the block appender to be a child block of its own, which also has
// this class.
const BLOCK_SELECTOR = '.wp-block';
const BLOCK_SELECTOR = '.block-editor-block-list__block';

/**
* Returns true if two elements are contained within the same block.
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,15 @@ export default compose( [
const selectedBlockHasDescendants = !! getClientIdsOfDescendants( [
selectedBlockId,
] )?.length;

return {
isImmediateParentOfSelectedBlock,
selectedBlockHasDescendants,
hasExistingNavItems: !! innerBlocks.length,

// This prop is already available but computing it here ensures it's
// fresh compared to isImmediateParentOfSelectedBlock
isSelected: selectedBlockId === clientId,
};
} ),
withDispatch( ( dispatch, { clientId } ) => {
Expand Down

0 comments on commit 108da99

Please sign in to comment.