Skip to content

Commit

Permalink
Switch back to document when unselecting blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 4, 2018
1 parent eef7947 commit 5af2602
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions edit-post/store/effects.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { reduce, values, some, get } from 'lodash';
import { reduce, values, some } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -92,10 +92,13 @@ const effects = {
INIT( _, store ) {
// Select the block settings tab when the selected block changes
subscribe( onChangeListener(
() => get( select( 'core/editor' ).getSelectedBlock(), 'uid' ),
( selectedBlockUid ) => {
if ( selectedBlockUid && select( 'core/edit-post' ).isEditorSidebarOpened() ) {
() => select( 'core/editor' ).getBlockSelectionStart(),
( selectionStart ) => {
const isSidebarOpened = select( 'core/edit-post' ).isEditorSidebarOpened();
if ( selectionStart && isSidebarOpened ) {
store.dispatch( openGeneralSidebar( 'edit-post/block' ) );
} else if ( ! selectionStart && isSidebarOpened ) {
store.dispatch( openGeneralSidebar( 'edit-post/document' ) );
}
} )
);
Expand Down

0 comments on commit 5af2602

Please sign in to comment.