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 2, 2018
1 parent eef7947 commit dcf9813
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions edit-post/store/effects.js
Original file line number Diff line number Diff line change
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 dcf9813

Please sign in to comment.