Skip to content

Commit

Permalink
Block Editor: Maintain selection when multi-selection toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jun 27, 2019
1 parent e36e448 commit 8213f92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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 @@ -809,7 +809,7 @@ export function blockSelection( state = BLOCK_SELECTION_INITIAL_STATE, action )
}
case 'TOGGLE_SELECTION':
return {
...BLOCK_SELECTION_INITIAL_STATE,
...state,
isEnabled: action.isSelectionEnabled,
};
case 'SELECTION_CHANGE':
Expand Down
18 changes: 18 additions & 0 deletions packages/block-editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,24 @@ describe( 'state', () => {
expect( state1 ).toBe( original );
} );

it( 'should maintain selection when toggling multi-selection', () => {
const original = deepFreeze( {
start: { clientId: 'ribs' },
end: { clientId: 'ribs' },
} );

const state = blockSelection( original, {
type: 'TOGGLE_SELECTION',
isSelectionEnabled: false,
} );

expect( state ).toEqual( {
start: { clientId: 'ribs' },
end: { clientId: 'ribs' },
isEnabled: false,
} );
} );

it( 'should unset multi selection', () => {
const original = deepFreeze( { start: { clientId: 'ribs' }, end: { clientId: 'chicken' } } );

Expand Down

0 comments on commit 8213f92

Please sign in to comment.