Skip to content

Commit eaf6715

Browse files
author
Gerardo Pacheco
authored
[Mobile] Moves block settings and more button to the toolbar (#52289)
* Remove BlockMobileToolbar * Refactor BlockSettingsButton * Update BlockToolbar with new order for buttons * Clean up BlockMobileToolbar refactor * Update EditorPage with new swipeToolbarToElement and updates removeBlock, toggleFormatting and addBlock helpers * Update E2E Tests * Update BlockList to remove inline block settings options * Update Gallery test * Update BlockDraggable test * Update BlockMover * EditorPage utils - Update swipeToolbarToElement to take into account swiping to the right
1 parent dbc146a commit eaf6715

File tree

19 files changed

+219
-361
lines changed

19 files changed

+219
-361
lines changed

packages/block-editor/src/components/block-draggable/test/index.native.js

-54
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ describe( 'BlockDraggable', () => {
133133
// "firePanGesture" finishes the dragging gesture
134134
firePanGesture( blockDraggableWrapper );
135135
expect( getDraggableChip( screen ) ).not.toBeDefined();
136-
137-
// Start dragging from block's mobile toolbar
138-
fireLongPress(
139-
paragraphBlock,
140-
'draggable-trigger-mobile-toolbar'
141-
);
142-
expect( getDraggableChip( screen ) ).toBeVisible();
143-
// "firePanGesture" finishes the dragging gesture
144-
firePanGesture( blockDraggableWrapper );
145-
expect( getDraggableChip( screen ) ).not.toBeDefined();
146136
} ) );
147137

148138
it( 'does not enable drag mode when selected and editing text', async () =>
@@ -243,16 +233,6 @@ describe( 'BlockDraggable', () => {
243233
// "firePanGesture" finishes the dragging gesture
244234
firePanGesture( blockDraggableWrapper );
245235
expect( getDraggableChip( screen ) ).not.toBeDefined();
246-
247-
// Start dragging from block's mobile toolbar
248-
fireLongPress(
249-
imageBlock,
250-
'draggable-trigger-mobile-toolbar'
251-
);
252-
expect( getDraggableChip( screen ) ).toBeVisible();
253-
// "firePanGesture" finishes the dragging gesture
254-
firePanGesture( blockDraggableWrapper );
255-
expect( getDraggableChip( screen ) ).not.toBeDefined();
256236
} ) );
257237
} );
258238

@@ -301,16 +281,6 @@ describe( 'BlockDraggable', () => {
301281
// "firePanGesture" finishes the dragging gesture
302282
firePanGesture( blockDraggableWrapper );
303283
expect( getDraggableChip( screen ) ).not.toBeDefined();
304-
305-
// Start dragging from block's mobile toolbar
306-
fireLongPress(
307-
galleryBlock,
308-
'draggable-trigger-mobile-toolbar'
309-
);
310-
expect( getDraggableChip( screen ) ).toBeVisible();
311-
// "firePanGesture" finishes the dragging gesture
312-
firePanGesture( blockDraggableWrapper );
313-
expect( getDraggableChip( screen ) ).not.toBeDefined();
314284
} ) );
315285

316286
it( 'enables drag mode when nested block is selected', async () =>
@@ -336,20 +306,6 @@ describe( 'BlockDraggable', () => {
336306
// "firePanGesture" finishes the dragging gesture
337307
firePanGesture( blockDraggableWrapper );
338308
expect( getDraggableChip( screen ) ).not.toBeDefined();
339-
340-
// After dropping the block, the gallery item gets automatically selected.
341-
// Hence, we have to select the gallery item again.
342-
fireEvent.press( galleryItem );
343-
344-
// Start dragging from nested block's mobile toolbar
345-
fireLongPress(
346-
galleryItem,
347-
'draggable-trigger-mobile-toolbar'
348-
);
349-
expect( getDraggableChip( screen ) ).toBeVisible();
350-
// "firePanGesture" finishes the dragging gesture
351-
firePanGesture( blockDraggableWrapper );
352-
expect( getDraggableChip( screen ) ).not.toBeDefined();
353309
} ) );
354310
} );
355311

@@ -390,16 +346,6 @@ describe( 'BlockDraggable', () => {
390346
// "firePanGesture" finishes the dragging gesture
391347
firePanGesture( blockDraggableWrapper );
392348
expect( getDraggableChip( screen ) ).not.toBeDefined();
393-
394-
// Start dragging from block's mobile toolbar
395-
fireLongPress(
396-
spacerBlock,
397-
'draggable-trigger-mobile-toolbar'
398-
);
399-
expect( getDraggableChip( screen ) ).toBeVisible();
400-
// "firePanGesture" finishes the dragging gesture
401-
firePanGesture( blockDraggableWrapper );
402-
expect( getDraggableChip( screen ) ).not.toBeDefined();
403349
} ) );
404350
} );
405351
} );

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

+1-29
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import { Pressable, useWindowDimensions, View } from 'react-native';
66
/**
77
* WordPress dependencies
88
*/
9-
import { useCallback, useMemo, useRef, useState } from '@wordpress/element';
9+
import { useCallback, useMemo, useState } from '@wordpress/element';
1010
import {
1111
GlobalStylesContext,
1212
getMergedGlobalStyles,
1313
useMobileGlobalStylesColors,
14-
alignmentHelpers,
1514
useGlobalStyles,
1615
} from '@wordpress/components';
1716
import {
@@ -36,9 +35,7 @@ import { compose, ifCondition, pure } from '@wordpress/compose';
3635
import BlockEdit from '../block-edit';
3736
import BlockDraggable from '../block-draggable';
3837
import BlockInvalidWarning from './block-invalid-warning';
39-
import BlockMobileToolbar from '../block-mobile-toolbar';
4038
import BlockOutline from './block-outline';
41-
import styles from './block.scss';
4239
import { store as blockEditorStore } from '../../store';
4340
import { useLayout } from './layout';
4441
import useSetting from '../use-setting';
@@ -63,27 +60,19 @@ function getWrapperProps( value, getWrapperPropsFunction ) {
6360

6461
function BlockWrapper( {
6562
accessibilityLabel,
66-
align,
67-
blockWidth,
6863
children,
6964
clientId,
7065
draggingClientId,
7166
draggingEnabled,
7267
isDescendentBlockSelected,
7368
isParentSelected,
7469
isSelected,
75-
isStackedHorizontally,
7670
isTouchable,
7771
marginHorizontal,
7872
marginVertical,
79-
onDeleteBlock,
8073
onFocus,
8174
} ) {
8275
const { width: screenWidth } = useWindowDimensions();
83-
const anchorNodeRef = useRef();
84-
const { isFullWidth } = alignmentHelpers;
85-
const isScreenWidthEqual = blockWidth === screenWidth;
86-
const isFullWidthToolbar = isFullWidth( align ) || isScreenWidthEqual;
8776
const blockWrapperStyles = { flex: 1 };
8877
const blockWrapperStyle = [
8978
blockWrapperStyles,
@@ -116,19 +105,6 @@ function BlockWrapper( {
116105
>
117106
{ children }
118107
</BlockDraggable>
119-
<View style={ styles.neutralToolbar } ref={ anchorNodeRef }>
120-
{ isSelected && (
121-
<BlockMobileToolbar
122-
anchorNodeRef={ anchorNodeRef.current }
123-
blockWidth={ blockWidth }
124-
clientId={ clientId }
125-
draggingClientId={ draggingClientId }
126-
isFullWidth={ isFullWidthToolbar }
127-
isStackedHorizontally={ isStackedHorizontally }
128-
onDelete={ onDeleteBlock }
129-
/>
130-
) }
131-
</View>
132108
</Pressable>
133109
);
134110
}
@@ -295,7 +271,6 @@ function BlockListBlock( {
295271
),
296272
] );
297273

298-
const { align } = attributes;
299274
const isFocused = isSelected || isDescendentBlockSelected;
300275
const isTouchable =
301276
isSelected ||
@@ -312,8 +287,6 @@ function BlockListBlock( {
312287
return (
313288
<BlockWrapper
314289
accessibilityLabel={ accessibilityLabel }
315-
align={ align }
316-
blockWidth={ blockWidth }
317290
clientId={ clientId }
318291
draggingClientId={ draggingClientId }
319292
draggingEnabled={ draggingEnabled }
@@ -325,7 +298,6 @@ function BlockListBlock( {
325298
isTouchable={ isTouchable }
326299
marginHorizontal={ marginHorizontal }
327300
marginVertical={ marginVertical }
328-
onDeleteBlock={ onDeleteBlock }
329301
onFocus={ onFocus }
330302
>
331303
{ () =>

packages/block-editor/src/components/block-list/block.native.scss

+1-6
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,10 @@
5151
min-height: 50px;
5252
}
5353

54-
.neutralToolbar {
55-
margin-left: -$block-edge-to-content;
56-
margin-right: -$block-edge-to-content;
57-
}
58-
5954
.solidBorder {
6055
position: absolute;
6156
top: -$solid-border-space;
62-
bottom: 0;
57+
bottom: -$solid-border-space;
6358
left: -$solid-border-space;
6459
right: -$solid-border-space;
6560
border-width: $block-selected-border-width;

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

-127
This file was deleted.

packages/block-editor/src/components/block-mobile-toolbar/style.native.scss

-16
This file was deleted.

packages/block-editor/src/components/block-mover/index.native.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Platform } from 'react-native';
77
* WordPress dependencies
88
*/
99
import { __ } from '@wordpress/i18n';
10-
import { Picker, ToolbarButton } from '@wordpress/components';
10+
import { Picker, ToolbarButton, ToolbarGroup } from '@wordpress/components';
1111
import { withInstanceId, compose } from '@wordpress/compose';
1212
import { withSelect, withDispatch } from '@wordpress/data';
1313
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
@@ -107,7 +107,7 @@ export const BlockMover = ( {
107107
}
108108

109109
return (
110-
<>
110+
<ToolbarGroup>
111111
<ToolbarButton
112112
title={ ! isFirst ? backwardButtonTitle : firstBlockTitle }
113113
isDisabled={ isFirst }
@@ -136,7 +136,7 @@ export const BlockMover = ( {
136136
leftAlign={ true }
137137
hideCancelButton={ Platform.OS !== 'ios' }
138138
/>
139-
</>
139+
</ToolbarGroup>
140140
);
141141
};
142142

0 commit comments

Comments
 (0)