Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block: remove outline related store selecting #61139

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ function BlockListBlockProvider( props ) {
hasSelectedInnerBlock,

getBlockIndex,
isTyping,
isBlockMultiSelected,
isBlockSubtreeDisabled,
isBlockHighlighted,
Expand Down Expand Up @@ -566,11 +565,8 @@ function BlockListBlockProvider( props ) {
const attributes = getBlockAttributes( clientId );
const { name: blockName, isValid } = blockWithoutAttributes;
const blockType = getBlockType( blockName );
const {
outlineMode,
supportsLayout,
__unstableIsPreviewMode: isPreviewMode,
} = getSettings();
const { supportsLayout, __unstableIsPreviewMode: isPreviewMode } =
getSettings();
const hasLightBlockWrapper = blockType?.apiVersion > 1;
const previewContext = {
isPreviewMode,
Expand Down Expand Up @@ -606,7 +602,6 @@ function BlockListBlockProvider( props ) {
clientId,
checkDeep
);
const typing = isTyping();
const movingClientId = hasBlockMovingClientId();
const blockEditingMode = getBlockEditingMode( clientId );

Expand Down Expand Up @@ -639,7 +634,6 @@ function BlockListBlockProvider( props ) {
isSubtreeDisabled:
blockEditingMode === 'disabled' &&
isBlockSubtreeDisabled( clientId ),
isOutlineEnabled: outlineMode,
hasOverlay:
__unstableHasActiveBlockOverlayActive( clientId ) &&
! isDragging(),
Expand All @@ -657,7 +651,6 @@ function BlockListBlockProvider( props ) {
! __unstableSelectionHasUnmergeableBlock(),
isDragging: isBlockBeingDragged( clientId ),
hasChildSelected: isAncestorOfSelectedBlock,
removeOutline: _isSelected && outlineMode && typing,
isBlockMovingMode: !! movingClientId,
canInsertMovingBlock:
movingClientId &&
Expand Down Expand Up @@ -697,7 +690,6 @@ function BlockListBlockProvider( props ) {
blockApiVersion,
blockTitle,
isSubtreeDisabled,
isOutlineEnabled,
hasOverlay,
initialPosition,
isHighlighted,
Expand All @@ -706,7 +698,6 @@ function BlockListBlockProvider( props ) {
isReusable,
isDragging,
hasChildSelected,
removeOutline,
isBlockMovingMode,
canInsertMovingBlock,
templateLock,
Expand Down Expand Up @@ -743,7 +734,6 @@ function BlockListBlockProvider( props ) {
blockTitle,
isSelected,
isSubtreeDisabled,
isOutlineEnabled,
hasOverlay,
initialPosition,
blockEditingMode,
Expand All @@ -753,7 +743,6 @@ function BlockListBlockProvider( props ) {
isReusable,
isDragging,
hasChildSelected,
removeOutline,
isBlockMovingMode,
canInsertMovingBlock,
templateLock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ _::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-b
}
}

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

Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ function Root( { className, ...settings } ) {
getSettings,
__unstableGetEditorMode,
getTemporarilyEditingAsBlocks,
isTyping,
} = unlock( select( blockEditorStore ) );
const { outlineMode, focusMode } = getSettings();
return {
isOutlineMode: outlineMode,
isOutlineMode: outlineMode && ! isTyping(),
isFocusMode: focusMode,
editorMode: __unstableGetEditorMode(),
temporarilyEditingAsBlocks: getTemporarilyEditingAsBlocks(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
blockTitle,
isSelected,
isSubtreeDisabled,
isOutlineEnabled,
hasOverlay,
initialPosition,
blockEditingMode,
Expand All @@ -96,7 +95,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
isReusable,
isDragging,
hasChildSelected,
removeOutline,
isBlockMovingMode,
canInsertMovingBlock,
isEditingDisabled,
Expand All @@ -116,7 +114,7 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
useFocusHandler( clientId ),
useEventHandlers( { clientId, isSelected } ),
useNavModeExit( clientId ),
useIsHovered( { isEnabled: isOutlineEnabled } ),
useIsHovered(),
useIntersectionObserver(),
useMovingAnimation( { triggerAnimationOnChange: index, clientId } ),
useDisabled( { isDisabled: ! hasOverlay } ),
Expand Down Expand Up @@ -179,7 +177,6 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
'is-reusable': isReusable,
'is-dragging': isDragging,
'has-child-selected': hasChildSelected,
'remove-outline': removeOutline,
'is-block-moving-mode': isBlockMovingMode,
'can-insert-moving-block': canInsertMovingBlock,
'is-editing-disabled': isEditingDisabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@ function listener( event ) {
* Adds `is-hovered` class when the block is hovered and in navigation or
* outline mode.
*/
export function useIsHovered( { isEnabled } ) {
return useRefEffect(
( node ) => {
if ( isEnabled ) {
node.addEventListener( 'mouseout', listener );
node.addEventListener( 'mouseover', listener );
export function useIsHovered() {
return useRefEffect( ( node ) => {
node.addEventListener( 'mouseout', listener );
node.addEventListener( 'mouseover', listener );

return () => {
node.removeEventListener( 'mouseout', listener );
node.removeEventListener( 'mouseover', listener );
return () => {
node.removeEventListener( 'mouseout', listener );
node.removeEventListener( 'mouseover', listener );

// Remove class in case it lingers.
node.classList.remove( 'is-hovered' );
};
}
},
[ isEnabled ]
);
// Remove class in case it lingers.
node.classList.remove( 'is-hovered' );
};
}, [] );
}
Loading