Skip to content

Commit

Permalink
move remove-outline to use-block-class-names
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed Jun 10, 2021
1 parent a005470 commit 71d7488
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
20 changes: 2 additions & 18 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import {
hasBlockSupport,
} from '@wordpress/blocks';
import { withFilters } from '@wordpress/components';
import {
withDispatch,
withSelect,
useDispatch,
useSelect,
} from '@wordpress/data';
import { withDispatch, withSelect, useDispatch } from '@wordpress/data';
import { compose, pure, ifCondition } from '@wordpress/compose';

/**
Expand Down Expand Up @@ -88,15 +83,6 @@ function BlockListBlock( {
const { removeBlock } = useDispatch( blockEditorStore );
const onRemove = useCallback( () => removeBlock( clientId ), [ clientId ] );

const removeBlockOutline = useSelect(
( select ) => {
const { isTyping, getSettings } = select( blockEditorStore );
const isOutlineMode = getSettings().outlineMode;
return isOutlineMode && isSelected && isTyping();
},
[ clientId, isSelected ]
);

// We wrap the BlockEdit component in a div that hides it when editing in
// HTML mode. This allows us to render all of the ancillary pieces
// (InspectorControls, etc.) which are inside `BlockEdit` but not
Expand Down Expand Up @@ -173,9 +159,7 @@ function BlockListBlock( {

const value = {
clientId,
className: removeBlockOutline
? classnames( className, 'remove-outline' )
: className,
className,
wrapperProps: omit( wrapperProps, [ 'data-align' ] ),
isAligned,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export function useBlockClassNames( clientId ) {
getBlockName,
getSettings,
hasSelectedInnerBlock,
isTyping,
__experimentalGetActiveBlockIdByBlockNames: getActiveBlockIdByBlockNames,
} = select( blockEditorStore );
const {
__experimentalSpotlightEntityBlocks: spotlightEntityBlocks,
outlineMode,
} = getSettings();
const isDragging = isBlockBeingDragged( clientId );
const isSelected = isBlockSelected( clientId );
Expand All @@ -59,6 +61,7 @@ export function useBlockClassNames( clientId ) {
'has-active-entity': activeEntityBlockId,
// Determine if there is an active entity area to spotlight.
'is-active-entity': activeEntityBlockId === clientId,
'remove-outline': isSelected && outlineMode && isTyping(),
} );
},
[ clientId ]
Expand Down

0 comments on commit 71d7488

Please sign in to comment.