Skip to content

Commit

Permalink
Block top toolbar: fix mover direction (#19574)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Jan 10, 2020
1 parent 684b4c2 commit 54aaba6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ function BlockListBlock( {
focusOnMount={ isToolbarForced }
data-type={ name }
data-align={ wrapperProps ? wrapperProps[ 'data-align' ] : undefined }
moverDirection={ moverDirection }
hasMovers={ hasMovers }
/>
);
Expand Down
19 changes: 16 additions & 3 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,38 @@ import MultiBlocksSwitcher from '../block-switcher/multi-blocks-switcher';
import BlockMover from '../block-mover';
import Inserter from '../inserter';

export default function BlockToolbar( { moverDirection, hasMovers = true } ) {
const { blockClientIds, isValid, mode, rootClientId } = useSelect( ( select ) => {
export default function BlockToolbar( { hasMovers = true } ) {
const {
blockClientIds,
isValid,
mode,
rootClientId,
moverDirection,
} = useSelect( ( select ) => {
const {
getBlockMode,
getSelectedBlockClientIds,
isBlockValid,
getBlockRootClientId,
getBlockListSettings,
} = select( 'core/block-editor' );
const selectedBlockClientIds = getSelectedBlockClientIds();
const blockRootClientId = getBlockRootClientId( selectedBlockClientIds[ 0 ] );

const {
__experimentalMoverDirection,
} = getBlockListSettings( blockRootClientId ) || {};

return {
blockClientIds: selectedBlockClientIds,
rootClientId: getBlockRootClientId( selectedBlockClientIds[ 0 ] ),
rootClientId: blockRootClientId,
isValid: selectedBlockClientIds.length === 1 ?
isBlockValid( selectedBlockClientIds[ 0 ] ) :
null,
mode: selectedBlockClientIds.length === 1 ?
getBlockMode( selectedBlockClientIds[ 0 ] ) :
null,
moverDirection: __experimentalMoverDirection,
};
}, [] );
const [ isInserterShown, setIsInserterShown ] = useState( false );
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ class InnerBlocks extends Component {
templateLock,
parentLock,
__experimentalCaptureToolbars,
__experimentalMoverDirection,
} = this.props;

const newSettings = {
allowedBlocks,
templateLock: templateLock === undefined ? parentLock : templateLock,
__experimentalCaptureToolbars: __experimentalCaptureToolbars || false,
__experimentalMoverDirection,
};

if ( ! isShallowEqual( blockListSettings, newSettings ) ) {
Expand Down

0 comments on commit 54aaba6

Please sign in to comment.