Skip to content

Commit

Permalink
Performance: Remove is-typing root class (#32567)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar authored and youknowriad committed Jun 14, 2021
1 parent 207ceec commit ad119ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
34 changes: 14 additions & 20 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,20 @@ export const IntersectionObserver = createContext();

function Root( { className, children } ) {
const isLargeViewport = useViewportMatch( 'medium' );
const {
isTyping,
isOutlineMode,
isFocusMode,
isNavigationMode,
} = useSelect( ( select ) => {
const {
isTyping: _isTyping,
getSettings,
isNavigationMode: _isNavigationMode,
} = select( blockEditorStore );
const { outlineMode, focusMode } = getSettings();
return {
isTyping: _isTyping(),
isOutlineMode: outlineMode,
isFocusMode: focusMode,
isNavigationMode: _isNavigationMode(),
};
}, [] );
const { isOutlineMode, isFocusMode, isNavigationMode } = useSelect(
( select ) => {
const { getSettings, isNavigationMode: _isNavigationMode } = select(
blockEditorStore
);
const { outlineMode, focusMode } = getSettings();
return {
isOutlineMode: outlineMode,
isFocusMode: focusMode,
isNavigationMode: _isNavigationMode(),
};
},
[]
);
return (
<div
ref={ useMergeRefs( [
Expand All @@ -57,7 +52,6 @@ function Root( { className, children } ) {
'block-editor-block-list__layout is-root-container',
className,
{
'is-typing': isTyping,
'is-outline-mode': isOutlineMode,
'is-focus-mode': isFocusMode && isLargeViewport,
'is-navigate-mode': isNavigationMode,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
}
}

.is-outline-mode:not(.is-typing) .block-editor-block-list__block {
.is-outline-mode .block-editor-block-list__block:not(.remove-outline) {
&.is-hovered {
cursor: default;

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 ad119ad

Please sign in to comment.