Skip to content

Commit 7ba0075

Browse files
authored
Revert moving is-typing class (#29608)
1 parent 912eb9e commit 7ba0075

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

packages/block-editor/src/components/block-list/block.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import {
1515
hasBlockSupport,
1616
} from '@wordpress/blocks';
1717
import { withFilters } from '@wordpress/components';
18-
import { withDispatch, withSelect, useDispatch } from '@wordpress/data';
18+
import {
19+
withDispatch,
20+
withSelect,
21+
useDispatch,
22+
useSelect,
23+
} from '@wordpress/data';
1924
import { compose, pure, ifCondition } from '@wordpress/compose';
2025

2126
/**
@@ -83,6 +88,21 @@ function BlockListBlock( {
8388
} ) {
8489
const { removeBlock } = useDispatch( blockEditorStore );
8590
const onRemove = useCallback( () => removeBlock( clientId ), [ clientId ] );
91+
const isTypingWithinBlock = useSelect(
92+
( select ) => {
93+
const { isTyping, hasSelectedInnerBlock } = select(
94+
blockEditorStore
95+
);
96+
return (
97+
// We only care about this prop when the block is selected
98+
// Thus to avoid unnecessary rerenders we avoid updating the
99+
// prop if the block is not selected.
100+
( isSelected || hasSelectedInnerBlock( clientId, true ) ) &&
101+
isTyping()
102+
);
103+
},
104+
[ clientId, isSelected ]
105+
);
86106

87107
// We wrap the BlockEdit component in a div that hides it when editing in
88108
// HTML mode. This allows us to render all of the ancillary pieces
@@ -163,7 +183,10 @@ function BlockListBlock( {
163183
isSelected,
164184
index,
165185
// The wp-block className is important for editor styles.
166-
className: classnames( className, { 'wp-block': ! isAligned } ),
186+
className: classnames( className, {
187+
'wp-block': ! isAligned,
188+
'is-typing': isTypingWithinBlock,
189+
} ),
167190
wrapperProps: omit( wrapperProps, [ 'data-align' ] ),
168191
};
169192
const memoizedValue = useMemo( () => value, Object.values( value ) );

packages/block-editor/src/components/block-list/use-block-props/use-block-class-names.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export function useBlockClassNames( clientId ) {
2727
return useSelect(
2828
( select ) => {
2929
const {
30-
isTyping,
3130
isBlockBeingDragged,
3231
isBlockHighlighted,
3332
isBlockSelected,
@@ -60,11 +59,6 @@ export function useBlockClassNames( clientId ) {
6059
'is-multi-selected': isBlockMultiSelected( clientId ),
6160
'is-reusable': isReusableBlock( getBlockType( name ) ),
6261
'is-dragging': isDragging,
63-
// We only care about this prop when the block is selected
64-
// Thus to avoid unnecessary rerenders we avoid updating the prop if
65-
// the block is not selected.
66-
'is-typing':
67-
( isSelected || isAncestorOfSelectedBlock ) && isTyping(),
6862
'is-focused':
6963
focusMode &&
7064
isLargeViewport &&

0 commit comments

Comments
 (0)