Skip to content

Commit

Permalink
Hide insertion point if in the context it would shown it is not possi…
Browse files Browse the repository at this point in the history
…ble to insert the default block

Insertion point has violating the allowedBlocks restriction of the parent block.
  • Loading branch information
jorgefilipecosta committed Jul 10, 2018
1 parent 7a878e0 commit a918ece
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions editor/components/block-list/insertion-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ class BlockInsertionPoint extends Component {
export default compose(
withSelect( ( select, { uid, rootUID, canShowInserter } ) => {
const {
canInsertBlockType,
getBlockIndex,
getBlockInsertionPoint,
getBlock,
isBlockInsertionPointVisible,
isTyping,
getTemplateLock,
} = select( 'core/editor' );
const {
getDefaultBlockName,
} = select( 'core/blocks' );
const blockIndex = uid ? getBlockIndex( uid, rootUID ) : -1;
const insertIndex = blockIndex;
const insertionPoint = getBlockInsertionPoint();
Expand All @@ -94,14 +97,15 @@ export default compose(
( ! block || ! isUnmodifiedDefaultBlock( block ) )
);

const defaultBlockName = getDefaultBlockName();
return {
isLocked: !! getTemplateLock( insertionPoint.rootUID ),
canInsertDefaultBlock: canInsertBlockType( defaultBlockName, rootUID ),
showInserter: ! isTyping() && canShowInserter,
index: insertIndex,
showInsertionPoint,
};
} ),
ifCondition( ( { isLocked } ) => ! isLocked ),
ifCondition( ( { canInsertDefaultBlock } ) => canInsertDefaultBlock ),
withDispatch( ( dispatch ) => {
const { insertDefaultBlock, startTyping } = dispatch( 'core/editor' );
return {
Expand Down

0 comments on commit a918ece

Please sign in to comment.