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

[Mobile] - Block selection - Expand tapping on nested blocks directly #50672

Merged
merged 5 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function BlockListBlock( {
blockType,
draggingClientId,
draggingEnabled,
firstToSelectId,
isDescendantOfParentSelected,
isDescendentBlockSelected,
isParentSelected,
Expand All @@ -174,7 +173,6 @@ function BlockListBlock( {
getBlockHierarchyRootClientId,
getBlockIndex,
getBlockParents,
getLowestCommonAncestorWithSelectedBlock,
getSelectedBlockClientId,
getSettings,
hasSelectedInnerBlock,
Expand All @@ -198,13 +196,6 @@ function BlockListBlock( {
selectedParents.includes( rootClientId );
const hasInnerBlocks = getBlockCount( clientId ) > 0;

const commonAncestor =
getLowestCommonAncestorWithSelectedBlock( clientId );
const commonAncestorIndex = parents.indexOf( commonAncestor ) - 1;
const firstBlockToSelectId = commonAncestor
? parents[ commonAncestorIndex ]
: parents[ parents.length - 1 ];

// For blocks with inner blocks, we only enable the dragging in the nested
// blocks if any of them are selected. This way we prevent the long-press
// gesture from being disabled for elements within the block UI.
Expand All @@ -223,7 +214,6 @@ function BlockListBlock( {
blockType: currentBlockType,
draggingClientId: currentDraggingClientId,
draggingEnabled: isDraggingEnabled,
firstToSelectId: firstBlockToSelectId,
isDescendantOfParentSelected: descendantOfParentSelected,
isDescendentBlockSelected: descendentBlockSelected,
isParentSelected: parentSelected,
Expand All @@ -245,11 +235,10 @@ function BlockListBlock( {
[ clientId, removeBlock ]
);
const onFocus = useCallback( () => {
const blockId = firstToSelectId ?? clientId;
if ( ! isSelected ) {
selectBlock( blockId );
selectBlock( clientId );
}
}, [ selectBlock, clientId, firstToSelectId, isSelected ] );
}, [ selectBlock, clientId, isSelected ] );

const onLayout = useCallback(
( { nativeEvent } ) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,19 @@ class EditorPage {
await toolBarButton.click();
}

async navigateUp() {
let navigateUpElements = [];
do {
await this.driver.sleep( 2000 );
navigateUpElements = await this.driver.elementsByAccessibilityId(
'Navigate Up'
);
if ( navigateUpElements.length > 0 ) {
await navigateUpElements[ 0 ].click();
}
} while ( navigateUpElements.length > 0 );
}

// =========================
// Inline toolbar functions
// =========================
Expand Down