Skip to content

Commit

Permalink
Use select param in withDispatch for Header component
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Nov 15, 2018
1 parent 23ed480 commit 6eb6826
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,17 @@ function Header( {
export default compose(
withSelect( ( select ) => ( {
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
isEditorSidebarOpened: select( 'core/edit-post' ).isEditorSidebarOpened(),
isPublishSidebarOpened: select( 'core/edit-post' ).isPublishSidebarOpened(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
} ) ),
withDispatch( ( dispatch, { hasBlockSelection } ) => {
withDispatch( ( dispatch, ownProps, select ) => {
const { getBlockSelectionStart } = select( 'core/editor' );
const { openGeneralSidebar, closeGeneralSidebar } = dispatch( 'core/edit-post' );
const sidebarToOpen = hasBlockSelection ? 'edit-post/block' : 'edit-post/document';

return {
openGeneralSidebar: () => openGeneralSidebar( sidebarToOpen ),
openGeneralSidebar: () => openGeneralSidebar( getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document' ),
closeGeneralSidebar: closeGeneralSidebar,
hasBlockSelection: undefined,
};
} ),
)( Header );

0 comments on commit 6eb6826

Please sign in to comment.