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 14, 2018
1 parent 06c53d6 commit a22ef38
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 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/edit-post' );
const { openGeneralSidebar, closeGeneralSidebar } = dispatch( 'core/edit-post' );
const sidebarToOpen = hasBlockSelection ? 'edit-post/block' : 'edit-post/document';
const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
return {
openGeneralSidebar: () => openGeneralSidebar( sidebarToOpen ),
closeGeneralSidebar: closeGeneralSidebar,
hasBlockSelection: undefined,
};
} ),
)( Header );

0 comments on commit a22ef38

Please sign in to comment.