Skip to content

Commit

Permalink
removed updateSelection from reducer so it's updated at all times.
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-alexander committed Apr 19, 2021
1 parent d22738f commit bb98f4c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ export function highlightedBlock( state, action ) {
export function lastBlockInserted( state = {}, action ) {
switch ( action.type ) {
case 'INSERT_BLOCKS':
if ( ! action.updateSelection || ! action.blocks.length ) {
if ( ! action.blocks.length ) {
return state;
}

Expand Down
26 changes: 0 additions & 26 deletions packages/block-editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,6 @@ describe( 'state', () => {
source: 'inserter_menu',
},
type: 'INSERT_BLOCKS',
updateSelection: true,
};

const state = lastBlockInserted( {}, action );
Expand All @@ -2981,37 +2980,13 @@ describe( 'state', () => {
source: expectedSource,
},
type: 'INSERT_BLOCKS',
updateSelection: true,
};

const state = lastBlockInserted( {}, action );

expect( state.source ).toBe( expectedSource );
} );

it( 'should return state if last block inserted is called with action INSERT_BLOCKS that is not a updateSelection', () => {
const expectedState = {
clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
};

const action = {
blocks: [
{
clientId: '62bfef6e-d5e9-43ba-b7f9-c77cf354141f',
},
],
meta: {
source: 'inserter_menu',
},
type: 'INSERT_BLOCKS',
updateSelection: false,
};

const state = lastBlockInserted( expectedState, action );

expect( state ).toEqual( expectedState );
} );

it( 'should return state if last block inserted is called with action INSERT_BLOCKS and block list is empty', () => {
const expectedState = {
clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
Expand All @@ -3023,7 +2998,6 @@ describe( 'state', () => {
source: 'inserter_menu',
},
type: 'INSERT_BLOCKS',
updateSelection: true,
};

const state = lastBlockInserted( expectedState, action );
Expand Down

0 comments on commit bb98f4c

Please sign in to comment.