Skip to content

Commit a850b5a

Browse files
committed
prep build 08/01
2 parents c9568bb + 1d9352f commit a850b5a

File tree

37 files changed

+644
-372
lines changed

37 files changed

+644
-372
lines changed

.github/workflows/enforce-pr-labels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
with:
1313
mode: exactly
1414
count: 1
15-
labels: '[Type] Accessibility (a11y), [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket'
15+
labels: '[Type] Accessibility (a11y), [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core'
1616
add_comment: true
1717
message: "## ⚠️ Type of PR label error\n To merge this PR, it requires {{ errorString }} {{ count }} label indicating the type of PR. Other labels are optional and not being checked here. \n- **Type-related labels to choose from**: {{ provided }}.\n- **Labels found**: {{ applied }}.\n\nYou can learn more about the Type labels in Gutenberg [here](https://github.com/WordPress/gutenberg/labels?q=type)"
1818
exit_type: failure

packages/block-editor/src/components/block-parent-selector/index.js

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useRef } from '@wordpress/element';
1212
*/
1313
import useBlockDisplayInformation from '../use-block-display-information';
1414
import BlockIcon from '../block-icon';
15-
import { useShowMoversGestures } from '../block-toolbar/utils';
15+
import { useShowHoveredOrFocusedGestures } from '../block-toolbar/utils';
1616
import { store as blockEditorStore } from '../../store';
1717
import { unlock } from '../../lock-unlock';
1818

@@ -23,52 +23,40 @@ import { unlock } from '../../lock-unlock';
2323
* @return {WPComponent} Parent block selector.
2424
*/
2525
export default function BlockParentSelector() {
26-
const { selectBlock, toggleBlockHighlight } =
27-
useDispatch( blockEditorStore );
28-
const { firstParentClientId, isVisible, isDistractionFree } = useSelect(
29-
( select ) => {
30-
const {
31-
getBlockName,
32-
getBlockParents,
33-
getSelectedBlockClientId,
34-
getSettings,
35-
getBlockEditingMode,
36-
} = unlock( select( blockEditorStore ) );
37-
const { hasBlockSupport } = select( blocksStore );
38-
const selectedBlockClientId = getSelectedBlockClientId();
39-
const parents = getBlockParents( selectedBlockClientId );
40-
const _firstParentClientId = parents[ parents.length - 1 ];
41-
const parentBlockName = getBlockName( _firstParentClientId );
42-
const _parentBlockType = getBlockType( parentBlockName );
43-
const settings = getSettings();
44-
return {
45-
firstParentClientId: _firstParentClientId,
46-
isVisible:
47-
_firstParentClientId &&
48-
getBlockEditingMode( _firstParentClientId ) === 'default' &&
49-
hasBlockSupport(
50-
_parentBlockType,
51-
'__experimentalParentSelector',
52-
true
53-
),
54-
isDistractionFree: settings.isDistractionFree,
55-
};
56-
},
57-
[]
58-
);
26+
const { selectBlock } = useDispatch( blockEditorStore );
27+
const { firstParentClientId, isVisible } = useSelect( ( select ) => {
28+
const {
29+
getBlockName,
30+
getBlockParents,
31+
getSelectedBlockClientId,
32+
getBlockEditingMode,
33+
} = unlock( select( blockEditorStore ) );
34+
const { hasBlockSupport } = select( blocksStore );
35+
const selectedBlockClientId = getSelectedBlockClientId();
36+
const parents = getBlockParents( selectedBlockClientId );
37+
const _firstParentClientId = parents[ parents.length - 1 ];
38+
const parentBlockName = getBlockName( _firstParentClientId );
39+
const _parentBlockType = getBlockType( parentBlockName );
40+
return {
41+
firstParentClientId: _firstParentClientId,
42+
isVisible:
43+
_firstParentClientId &&
44+
getBlockEditingMode( _firstParentClientId ) === 'default' &&
45+
hasBlockSupport(
46+
_parentBlockType,
47+
'__experimentalParentSelector',
48+
true
49+
),
50+
};
51+
}, [] );
5952
const blockInformation = useBlockDisplayInformation( firstParentClientId );
6053

6154
// Allows highlighting the parent block outline when focusing or hovering
6255
// the parent block selector within the child.
6356
const nodeRef = useRef();
64-
const { gestures: showMoversGestures } = useShowMoversGestures( {
57+
const showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {
6558
ref: nodeRef,
66-
onChange( isFocused ) {
67-
if ( isFocused && isDistractionFree ) {
68-
return;
69-
}
70-
toggleBlockHighlight( firstParentClientId, isFocused );
71-
},
59+
highlightParent: true,
7260
} );
7361

7462
if ( ! isVisible ) {
@@ -80,7 +68,7 @@ export default function BlockParentSelector() {
8068
className="block-editor-block-parent-selector"
8169
key={ firstParentClientId }
8270
ref={ nodeRef }
83-
{ ...showMoversGestures }
71+
{ ...showHoveredOrFocusedGestures }
8472
>
8573
<ToolbarButton
8674
className="block-editor-block-parent-selector__button"

packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import BlockHTMLConvertButton from './block-html-convert-button';
3131
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
3232
import BlockSettingsMenuControls from '../block-settings-menu-controls';
3333
import { store as blockEditorStore } from '../../store';
34-
import { useShowMoversGestures } from '../block-toolbar/utils';
34+
import { useShowHoveredOrFocusedGestures } from '../block-toolbar/utils';
3535

3636
const POPOVER_PROPS = {
3737
className: 'block-editor-block-settings-menu__popover',
@@ -60,7 +60,6 @@ export function BlockSettingsDropdown( {
6060
const firstBlockClientId = blockClientIds[ 0 ];
6161
const {
6262
firstParentClientId,
63-
isDistractionFree,
6463
onlyBlock,
6564
parentBlockType,
6665
previousBlockClientId,
@@ -73,7 +72,6 @@ export function BlockSettingsDropdown( {
7372
getBlockRootClientId,
7473
getPreviousBlockClientId,
7574
getSelectedBlockClientIds,
76-
getSettings,
7775
getBlockAttributes,
7876
} = select( blockEditorStore );
7977

@@ -86,7 +84,6 @@ export function BlockSettingsDropdown( {
8684

8785
return {
8886
firstParentClientId: _firstParentClientId,
89-
isDistractionFree: getSettings().isDistractionFree,
9087
onlyBlock: 1 === getBlockCount( _firstParentClientId ),
9188
parentBlockType:
9289
_firstParentClientId &&
@@ -122,8 +119,7 @@ export function BlockSettingsDropdown( {
122119
}, [] );
123120
const isMatch = __unstableUseShortcutEventMatch();
124121

125-
const { selectBlock, toggleBlockHighlight } =
126-
useDispatch( blockEditorStore );
122+
const { selectBlock } = useDispatch( blockEditorStore );
127123
const hasSelectedBlocks = selectedBlockClientIds.length > 0;
128124

129125
const updateSelectionAfterDuplicate = useCallback(
@@ -168,14 +164,9 @@ export function BlockSettingsDropdown( {
168164
// Allows highlighting the parent block outline when focusing or hovering
169165
// the parent block selector within the child.
170166
const selectParentButtonRef = useRef();
171-
const { gestures: showParentOutlineGestures } = useShowMoversGestures( {
167+
const showParentOutlineGestures = useShowHoveredOrFocusedGestures( {
172168
ref: selectParentButtonRef,
173-
onChange( isFocused ) {
174-
if ( isFocused && isDistractionFree ) {
175-
return;
176-
}
177-
toggleBlockHighlight( firstParentClientId, isFocused );
178-
},
169+
highlightParent: true,
179170
} );
180171

181172
// This can occur when the selected block (the parent)

packages/block-editor/src/components/block-toolbar/index.js

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9-
import { useSelect, useDispatch } from '@wordpress/data';
9+
import { useSelect } from '@wordpress/data';
1010
import { useRef } from '@wordpress/element';
1111
import { useViewportMatch } from '@wordpress/compose';
1212
import {
@@ -29,76 +29,52 @@ import BlockSettingsMenu from '../block-settings-menu';
2929
import { BlockLockToolbar } from '../block-lock';
3030
import { BlockGroupToolbar } from '../convert-to-group-buttons';
3131
import BlockEditVisuallyButton from '../block-edit-visually-button';
32-
import { useShowMoversGestures } from './utils';
32+
import { useShowHoveredOrFocusedGestures } from './utils';
3333
import { store as blockEditorStore } from '../../store';
3434
import __unstableBlockNameContext from './block-name-context';
3535
import { unlock } from '../../lock-unlock';
3636

3737
const BlockToolbar = ( { hideDragHandle } ) => {
38-
const { getSelectedBlockClientId } = useSelect( blockEditorStore );
39-
const {
40-
blockClientIds,
41-
blockType,
42-
hasFixedToolbar,
43-
isDistractionFree,
44-
isValid,
45-
isVisual,
46-
blockEditingMode,
47-
} = useSelect( ( select ) => {
48-
const {
49-
getBlockName,
50-
getBlockMode,
51-
getSelectedBlockClientIds,
52-
isBlockValid,
53-
getBlockRootClientId,
54-
getSettings,
55-
getBlockEditingMode,
56-
} = unlock( select( blockEditorStore ) );
57-
const selectedBlockClientIds = getSelectedBlockClientIds();
58-
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
59-
const blockRootClientId = getBlockRootClientId( selectedBlockClientId );
60-
const settings = getSettings();
61-
62-
return {
63-
blockClientIds: selectedBlockClientIds,
64-
blockType:
65-
selectedBlockClientId &&
66-
getBlockType( getBlockName( selectedBlockClientId ) ),
67-
hasFixedToolbar: settings.hasFixedToolbar,
68-
isDistractionFree: settings.isDistractionFree,
69-
rootClientId: blockRootClientId,
70-
isValid: selectedBlockClientIds.every( ( id ) =>
71-
isBlockValid( id )
72-
),
73-
isVisual: selectedBlockClientIds.every(
74-
( id ) => getBlockMode( id ) === 'visual'
75-
),
76-
blockEditingMode: getBlockEditingMode( selectedBlockClientId ),
77-
};
78-
}, [] );
38+
const { blockClientIds, blockType, isValid, isVisual, blockEditingMode } =
39+
useSelect( ( select ) => {
40+
const {
41+
getBlockName,
42+
getBlockMode,
43+
getSelectedBlockClientIds,
44+
isBlockValid,
45+
getBlockRootClientId,
46+
getBlockEditingMode,
47+
} = unlock( select( blockEditorStore ) );
48+
const selectedBlockClientIds = getSelectedBlockClientIds();
49+
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
50+
const blockRootClientId = getBlockRootClientId(
51+
selectedBlockClientId
52+
);
53+
return {
54+
blockClientIds: selectedBlockClientIds,
55+
blockType:
56+
selectedBlockClientId &&
57+
getBlockType( getBlockName( selectedBlockClientId ) ),
58+
rootClientId: blockRootClientId,
59+
isValid: selectedBlockClientIds.every( ( id ) =>
60+
isBlockValid( id )
61+
),
62+
isVisual: selectedBlockClientIds.every(
63+
( id ) => getBlockMode( id ) === 'visual'
64+
),
65+
blockEditingMode: getBlockEditingMode( selectedBlockClientId ),
66+
};
67+
}, [] );
7968

8069
const toolbarWrapperRef = useRef( null );
8170

8271
// Handles highlighting the current block outline on hover or focus of the
8372
// block type toolbar area.
84-
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
8573
const nodeRef = useRef();
86-
const { showMovers, gestures: showMoversGestures } = useShowMoversGestures(
87-
{
88-
ref: nodeRef,
89-
onChange( isFocused ) {
90-
if ( isFocused && isDistractionFree ) {
91-
return;
92-
}
93-
toggleBlockHighlight( getSelectedBlockClientId(), isFocused );
94-
},
95-
}
96-
);
74+
const showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {
75+
ref: nodeRef,
76+
} );
9777

98-
// Account for the cases where the block toolbar is rendered within the
99-
// header area and not contextually to the block.
100-
const displayHeaderToolbar =
101-
useViewportMatch( 'medium', '<' ) || hasFixedToolbar;
10278
const isLargeViewport = ! useViewportMatch( 'medium', '<' );
10379

10480
if ( blockType ) {
@@ -107,8 +83,6 @@ const BlockToolbar = ( { hideDragHandle } ) => {
10783
}
10884
}
10985

110-
const shouldShowMovers = displayHeaderToolbar || showMovers;
111-
11286
if ( blockClientIds.length === 0 ) {
11387
return null;
11488
}
@@ -119,7 +93,6 @@ const BlockToolbar = ( { hideDragHandle } ) => {
11993
isReusableBlock( blockType ) || isTemplatePart( blockType );
12094

12195
const classes = classnames( 'block-editor-block-toolbar', {
122-
'is-showing-movers': shouldShowMovers,
12396
'is-synced': isSynced,
12497
} );
12598

@@ -130,7 +103,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
130103
blockEditingMode === 'default' && <BlockParentSelector /> }
131104
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
132105
blockEditingMode === 'default' && (
133-
<div ref={ nodeRef } { ...showMoversGestures }>
106+
<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>
134107
<ToolbarGroup className="block-editor-block-toolbar__block-controls">
135108
<BlockSwitcher clientIds={ blockClientIds } />
136109
{ ! isMultiToolbar && (

0 commit comments

Comments
 (0)