Skip to content

Commit

Permalink
Make sidebar toggle button open block sidebar if a block is selected (#…
Browse files Browse the repository at this point in the history
…6690)

When opening sidebar we always opened document sidebar. This stopped the behaviour of keeping block sidebar opened while a block is selected.
  • Loading branch information
jorgefilipecosta authored May 11, 2018
1 parent 0ab0deb commit 368dc63
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions edit-post/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ export default compose(
isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
} ) ),
withDispatch( ( dispatch ) => ( {
openGeneralSidebar: () => dispatch( 'core/edit-post' ).openGeneralSidebar( 'edit-post/document' ),
closeGeneralSidebar: dispatch( 'core/edit-post' ).closeGeneralSidebar,
togglePublishSidebar: dispatch( 'core/edit-post' ).togglePublishSidebar,
} ) ),
withDispatch( ( dispatch, { hasBlockSelection } ) => {
const { openGeneralSidebar, closeGeneralSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' );
const sidebarToOpen = hasBlockSelection ? 'edit-post/block' : 'edit-post/document';
return {
openGeneralSidebar: () => openGeneralSidebar( sidebarToOpen ),
closeGeneralSidebar: closeGeneralSidebar,
togglePublishSidebar: togglePublishSidebar,
hasBlockSelection: undefined,
};
} ),
)( Header );

0 comments on commit 368dc63

Please sign in to comment.