Skip to content

Commit

Permalink
Escape out of block moving mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Jun 17, 2020
1 parent 49b3ce1 commit d597ac0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ function BlockSelectionButton( {
const { name, attributes } = __unstableGetBlockWithoutInnerBlocks(
clientId
);
return { index, name, attributes, isBlockMovingMode };
const blockMovingMode = isBlockMovingMode();
return { index, name, attributes, blockMovingMode };
},
[ clientId, rootClientId ]
);
const { index, name, attributes, isBlockMovingMode } = selected;
const { index, name, attributes, blockMovingMode } = selected;
const { setNavigationMode, removeBlock } = useDispatch(
'core/block-editor'
);
Expand Down Expand Up @@ -82,7 +83,7 @@ function BlockSelectionButton( {
const classNames = classnames(
'block-editor-block-list__block-selection-button',
{
'is-navigate-mode': !! isBlockMovingMode(),
'is-block-moving-mode': !! blockMovingMode,
}
);

Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@
}


.is-navigate-mode.block-editor-block-list__breadcrumb {
.is-block-moving-mode.block-editor-block-list__breadcrumb {
// Should be invisible but not unfocusable.
opacity: 0;
font-size: 1px;
height: 1px;
padding: 0;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/block-editor/src/components/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,10 @@ export default function WritingFlow( { children } ) {
)
);
}

if ( isEscape && startingBlockClientId ) {
setBlockMovingMode( null );
setCanInsertMovingBlock( false );
}
if ( ( isEnter || isSpace ) && startingBlockClientId ) {
const sourceRoot = getBlockRootClientId(
startingBlockClientId
Expand Down

0 comments on commit d597ac0

Please sign in to comment.