From c8c4d227f4f095b2e32bd236662245c654413059 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 4 Jun 2018 12:21:48 +1000 Subject: [PATCH] NUX: Only show inserter tip in DefaultBlockAppender Only display the first DotTip in the new user guide in the DefaultBlockAppender that appears in a new post. This prevents the guide from appearing in an existing post that contains empty blocks. --- editor/components/block-list/block.js | 14 ++------------ editor/components/default-block-appender/index.js | 9 ++++++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/editor/components/block-list/block.js b/editor/components/block-list/block.js index 5e9db9ccec6b7f..70eb8f82088c9e 100644 --- a/editor/components/block-list/block.js +++ b/editor/components/block-list/block.js @@ -28,7 +28,6 @@ import { withFilters } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { withDispatch, withSelect } from '@wordpress/data'; import { withViewportMatch } from '@wordpress/viewport'; -import { DotTip } from '@wordpress/nux'; /** * Internal dependencies @@ -415,7 +414,6 @@ export class BlockListBlock extends Component { isEmptyDefaultBlock, isPreviousBlockADefaultEmptyBlock, hasSelectedInnerBlock, - hasTip, } = this.props; const isHovered = this.state.isHovered && ! isMultiSelecting; const { name: blockName, isValid } = block; @@ -428,7 +426,7 @@ export class BlockListBlock extends Component { // If the block is selected and we're typing the block should not appear. // Empty paragraph blocks should always show up as unselected. const showEmptyBlockSideInserter = ( isSelected || isHovered ) && isEmptyDefaultBlock; - const showSideInserter = ( isSelected || isHovered || hasTip ) && isEmptyDefaultBlock; + const showSideInserter = ( isSelected || isHovered ) && isEmptyDefaultBlock; const shouldAppearSelected = ! showSideInserter && ( isSelected || hasSelectedInnerBlock ) && ! isTypingWithinBlock; // We render block movers and block settings to keep them tabbale even if hidden const shouldRenderMovers = ( isSelected || hoverArea === 'left' ) && ! showEmptyBlockSideInserter && ! isMultiSelecting && ! isMultiSelected && ! isTypingWithinBlock; @@ -597,11 +595,7 @@ export class BlockListBlock extends Component { - - { __( 'Welcome to the wonderful world of blocks! Click ‘Add block’ to insert different kinds of content—text, images, quotes, video, lists, and much more.' ) } - - + /> ) } @@ -629,9 +623,6 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => { getEditorSettings, hasSelectedInnerBlock, } = select( 'core/editor' ); - - const { isTipVisible } = select( 'core/nux' ); - const isSelected = isBlockSelected( uid ); const isParentOfSelectedBlock = hasSelectedInnerBlock( uid ); const { templateLock, hasFixedToolbar } = getEditorSettings(); @@ -660,7 +651,6 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => { block, isSelected, hasFixedToolbar, - hasTip: isTipVisible( 'core/editor.inserter' ), }; } ); diff --git a/editor/components/default-block-appender/index.js b/editor/components/default-block-appender/index.js index ad5c4e14d1d7d4..5a844824ba62b4 100644 --- a/editor/components/default-block-appender/index.js +++ b/editor/components/default-block-appender/index.js @@ -88,9 +88,12 @@ export default compose( insertDefaultBlock, startTyping, } = dispatch( 'core/editor' ); + + const { dismissTip } = dispatch( 'core/nux' ); + return { onAppend() { - const { layout, rootUID } = ownProps; + const { layout, rootUID, hasTip } = ownProps; let attributes; if ( layout ) { @@ -99,6 +102,10 @@ export default compose( insertDefaultBlock( attributes, rootUID ); startTyping(); + + if ( hasTip ) { + dismissTip( 'core/editor.inserter' ); + } }, }; } ),