Skip to content

Commit

Permalink
Select parent block when switching to exploded mode
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 27, 2022
1 parent 998793c commit b80b932
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/block-editor/src/store/actions.js
Expand Up @@ -1440,7 +1440,17 @@ export const setNavigationMode = ( isNavigationMode = true ) => ( {
*
* @param {string} mode Editor mode
*/
export const __unstableSetEditorMode = ( mode ) => ( { dispatch } ) => {
export const __unstableSetEditorMode = ( mode ) => ( { dispatch, select } ) => {
// When switching to exploded mode, we need to select to parent block
if ( mode === 'exploded' ) {
const firstSelectedClientId = select.getBlockSelectionStart();
if ( firstSelectedClientId ) {
dispatch.selectBlock(
select.getBlockHierarchyRootClientId( firstSelectedClientId )
);
}
}

dispatch( { type: 'SET_EDITOR_MODE', mode } );

if ( mode === 'navigation' ) {
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/header/index.js
Expand Up @@ -142,7 +142,10 @@ export default function Header( {
<RedoButton />
<Button
className="edit-site-header-toolbar__list-view-toggle"
disabled={ ! isVisualMode }
disabled={
! isVisualMode &&
blockEditorMode === 'exploded'
}
icon={ listView }
isPressed={ isListViewOpen }
/* translators: button label text should, if possible, be under 16 characters. */
Expand Down

0 comments on commit b80b932

Please sign in to comment.