Skip to content

Commit

Permalink
Remove the deprecation and force the prop name change
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons committed Mar 22, 2021
1 parent 9aba7a2 commit f2fdc47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
27 changes: 1 addition & 26 deletions packages/block-editor/src/components/block-navigation/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/

import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
import deprecated from '@wordpress/deprecated';
import { useMemo, useRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
/**
Expand All @@ -21,14 +20,10 @@ import useBlockNavigationDropZone from './use-block-navigation-drop-zone';
* @param {Object} props Components props.
* @param {boolean} props.__experimentalFeatures Flag to enable experimental features.
* @param {boolean} props.__experimentalPersistentListViewFeatures Flag to enable features for the Persistent List View experiment.
* @param {string} props.selectedBlockClientId Deprecated. See props.selectedBlockClientIds.
* @param {Array} props.selectedBlockClientIds List of selected block client IDs.
*/
export default function BlockNavigationTree( {
__experimentalFeatures,
__experimentalPersistentListViewFeatures,
selectedBlockClientId,
selectedBlockClientIds,
...props
} ) {
const treeGridRef = useRef();
Expand All @@ -51,34 +46,14 @@ export default function BlockNavigationTree( {
]
);

// Deprecate selectedBlockClientId
if ( selectedBlockClientId ) {
deprecated(
'selectedBlockClientId (singular) prop of the BlockNavigationTree component',
{
alternative:
'selectedBlockClientIds (renamed to plural) of the BlockNavigationTree component',
hint: 'The renamed prop is an array',
}
);
}
// Convert selectedBlockClientId to selectedBlockClientIds for backward compatibility.
const updatedProps = {
...props,
selectedBlockClientIds:
selectedBlockClientId && ! selectedBlockClientIds
? [ selectedBlockClientId ]
: selectedBlockClientIds,
};

return (
<TreeGrid
className="block-editor-block-navigation-tree"
aria-label={ __( 'Block navigation structure' ) }
ref={ treeGridRef }
>
<BlockNavigationContext.Provider value={ contextValue }>
<BlockNavigationBranch { ...updatedProps } />
<BlockNavigationBranch { ...props } />
</BlockNavigationContext.Provider>
</TreeGrid>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/block-editor/src/components/block-navigation/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export const getBlockPositionDescription = ( position, siblingCount, level ) =>
* Returns true if the client ID occurs within the block selection or multi-selection,
* or false otherwise.
*
* @param {string} clientId Block client ID.
* @param {string|string[]} selectedBlockClientId Selected block client ID, or an array of multi-selected blocks client IDs.
* @param {string} clientId Block client ID.
* @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.
*
* @return {boolean} Whether the block is in multi-selection set.
*/
export const isClientIdSelected = ( clientId, selectedBlockClientId ) =>
isArray( selectedBlockClientId ) && selectedBlockClientId.length
? selectedBlockClientId.indexOf( clientId ) !== -1
: selectedBlockClientId === clientId;
export const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>
isArray( selectedBlockClientIds ) && selectedBlockClientIds.length
? selectedBlockClientIds.indexOf( clientId ) !== -1
: selectedBlockClientIds === clientId;

0 comments on commit f2fdc47

Please sign in to comment.