Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename isProvisionalBlock action property to selectPrevious in removeBlock and removeBlocks #5696

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions editor/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,30 +381,30 @@ export function createUndoLevel() {
* Returns an action object used in signalling that the blocks
* corresponding to the specified UID set are to be removed.
*
* @param {string[]} uids Block UIDs.
* @param {boolean} isProvisionalBlock True if the action is being used to remove a provisional block.
* @param {string[]} uids Block UIDs.
* @param {boolean} selectPrevious True if the previous block should be selected when a block is removed.
*
* @return {Object} Action object.
*/
export function removeBlocks( uids, isProvisionalBlock = false ) {
export function removeBlocks( uids, selectPrevious = true ) {
return {
type: 'REMOVE_BLOCKS',
uids,
isProvisionalBlock,
selectPrevious,
};
}

/**
* Returns an action object used in signalling that the block with the
* specified UID is to be removed.
*
* @param {string} uid Block UID.
* @param {boolean} isProvisionalBlock True if the action is being used to remove a provisional block.
* @param {string} uid Block UID.
* @param {boolean} selectPrevious True if the previous block should be selected when a block is removed.
*
* @return {Object} Action object.
*/
export function removeBlock( uid, isProvisionalBlock = false ) {
return removeBlocks( [ uid ], isProvisionalBlock );
export function removeBlock( uid, selectPrevious = true ) {
return removeBlocks( [ uid ], selectPrevious );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions editor/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function removeProvisionalBlock( action, store ) {
const state = store.getState();
const provisionalBlockUID = getProvisionalBlockUID( state );
if ( provisionalBlockUID && ! isBlockSelected( state, provisionalBlockUID ) ) {
return removeBlock( provisionalBlockUID, true );
return removeBlock( provisionalBlockUID, false );
}
}

Expand Down Expand Up @@ -572,8 +572,8 @@ export default {
MULTI_SELECT: removeProvisionalBlock,

REMOVE_BLOCKS( action, { getState, dispatch } ) {
// if we are removing the provisional block don't do anything.
if ( action.isProvisionalBlock ) {
// if the action says previous block should not be selected don't do anything.
if ( ! action.selectPrevious ) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions editor/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe( 'actions', () => {
expect( removeBlocks( uids ) ).toEqual( {
type: 'REMOVE_BLOCKS',
uids,
isProvisionalBlock: false,
selectPrevious: true,
} );
} );
} );
Expand All @@ -314,14 +314,14 @@ describe( 'actions', () => {
uids: [
uid,
],
isProvisionalBlock: false,
selectPrevious: true,
} );
expect( removeBlock( uid, true ) ).toEqual( {
expect( removeBlock( uid, false ) ).toEqual( {
type: 'REMOVE_BLOCKS',
uids: [
uid,
],
isProvisionalBlock: true,
selectPrevious: false,
} );
} );
} );
Expand Down
2 changes: 1 addition & 1 deletion editor/store/test/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe( 'effects', () => {
selectors.isBlockSelected.mockImplementation( ( state, uid ) => uid === 'ribs' );
const action = removeProvisionalBlock( {}, store );

expect( action ).toEqual( removeBlock( 'chicken', true ) );
expect( action ).toEqual( removeBlock( 'chicken', false ) );
} );
} );

Expand Down