Skip to content

Commit

Permalink
NUX: Only show inserter tip in DefaultBlockAppender
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
noisysocks committed Jun 7, 2018
1 parent ff09643 commit c8c4d22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
14 changes: 2 additions & 12 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -597,11 +595,7 @@ export class BlockListBlock extends Component {
<Inserter
position="top right"
onToggle={ this.selectOnOpen }
>
<DotTip id="core/editor.inserter">
{ __( 'Welcome to the wonderful world of blocks! Click ‘Add block’ to insert different kinds of content—text, images, quotes, video, lists, and much more.' ) }
</DotTip>
</Inserter>
/>
</div>
</Fragment>
) }
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -660,7 +651,6 @@ const applyWithSelect = withSelect( ( select, { uid, rootUID } ) => {
block,
isSelected,
hasFixedToolbar,
hasTip: isTipVisible( 'core/editor.inserter' ),
};
} );

Expand Down
9 changes: 8 additions & 1 deletion editor/components/default-block-appender/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -99,6 +102,10 @@ export default compose(

insertDefaultBlock( attributes, rootUID );
startTyping();

if ( hasTip ) {
dismissTip( 'core/editor.inserter' );
}
},
};
} ),
Expand Down

0 comments on commit c8c4d22

Please sign in to comment.