Skip to content

Commit

Permalink
Revert moving is-typing class (#29608)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Mar 8, 2021
1 parent 912eb9e commit 7ba0075
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
27 changes: 25 additions & 2 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
hasBlockSupport,
} from '@wordpress/blocks';
import { withFilters } from '@wordpress/components';
import { withDispatch, withSelect, useDispatch } from '@wordpress/data';
import {
withDispatch,
withSelect,
useDispatch,
useSelect,
} from '@wordpress/data';
import { compose, pure, ifCondition } from '@wordpress/compose';

/**
Expand Down Expand Up @@ -83,6 +88,21 @@ function BlockListBlock( {
} ) {
const { removeBlock } = useDispatch( blockEditorStore );
const onRemove = useCallback( () => removeBlock( clientId ), [ clientId ] );
const isTypingWithinBlock = useSelect(
( select ) => {
const { isTyping, hasSelectedInnerBlock } = select(
blockEditorStore
);
return (
// We only care about this prop when the block is selected
// Thus to avoid unnecessary rerenders we avoid updating the
// prop if the block is not selected.
( isSelected || hasSelectedInnerBlock( clientId, true ) ) &&
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
Expand Down Expand Up @@ -163,7 +183,10 @@ function BlockListBlock( {
isSelected,
index,
// The wp-block className is important for editor styles.
className: classnames( className, { 'wp-block': ! isAligned } ),
className: classnames( className, {
'wp-block': ! isAligned,
'is-typing': isTypingWithinBlock,
} ),
wrapperProps: omit( wrapperProps, [ 'data-align' ] ),
};
const memoizedValue = useMemo( () => value, Object.values( value ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function useBlockClassNames( clientId ) {
return useSelect(
( select ) => {
const {
isTyping,
isBlockBeingDragged,
isBlockHighlighted,
isBlockSelected,
Expand Down Expand Up @@ -60,11 +59,6 @@ export function useBlockClassNames( clientId ) {
'is-multi-selected': isBlockMultiSelected( clientId ),
'is-reusable': isReusableBlock( getBlockType( name ) ),
'is-dragging': isDragging,
// We only care about this prop when the block is selected
// Thus to avoid unnecessary rerenders we avoid updating the prop if
// the block is not selected.
'is-typing':
( isSelected || isAncestorOfSelectedBlock ) && isTyping(),
'is-focused':
focusMode &&
isLargeViewport &&
Expand Down

0 comments on commit 7ba0075

Please sign in to comment.