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 Jun 8, 2018
1 parent c7ce08b commit 39f819c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion editor/components/block-list/insertion-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ class BlockInsertionPoint extends Component {
export default compose(
withSelect( ( select, { uid, rootUID, canShowInserter } ) => {
const {
canInsertBlockType,
getBlockIndex,
getBlockInsertionPoint,
getBlock,
isBlockInsertionPointVisible,
isTyping,
getEditorSettings,
} = select( 'core/editor' );
const {
getDefaultBlockName,
} = select( 'core/blocks' );
const blockIndex = uid ? getBlockIndex( uid, rootUID ) : -1;
const insertIndex = blockIndex;
const insertionPoint = getBlockInsertionPoint();
Expand All @@ -91,14 +95,16 @@ export default compose(
( ! block || ! isUnmodifiedDefaultBlock( block ) )
);

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

0 comments on commit 39f819c

Please sign in to comment.