From a5d7295f11980d357bd04251cfa9fdd9fe5e7cc8 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 10 Jul 2018 14:35:32 -0400 Subject: [PATCH] Block API: Deprecate `id` prop in favor of `clientId` (#7669) --- docs/reference/deprecated.md | 1 + edit-post/index.js | 9 +++++++++ editor/components/block-list/block.js | 1 + 3 files changed, 11 insertions(+) diff --git a/docs/reference/deprecated.md b/docs/reference/deprecated.md index 9dba0fa8879b4..ea5c2c54fda1f 100644 --- a/docs/reference/deprecated.md +++ b/docs/reference/deprecated.md @@ -4,6 +4,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo - `focusOnMount` prop in the `Popover` component has been changed from `Boolean`-only to an enum-style property that accepts `"firstElement"`, `"container"`, or `false`. Please convert any `` usage to ``. - `wp.utils.keycodes` utilities are removed. Please use `wp.keycodes` instead. + - Block `id` prop in `edit` function removed. Please use block `clientId` prop instead. ## 3.3.0 diff --git a/edit-post/index.js b/edit-post/index.js index cc5692681050c..ebb223771a357 100644 --- a/edit-post/index.js +++ b/edit-post/index.js @@ -4,6 +4,7 @@ import { registerCoreBlocks } from '@wordpress/core-blocks'; import { render, unmountComponentAtNode } from '@wordpress/element'; import { dispatch } from '@wordpress/data'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -53,6 +54,14 @@ export function initializeEditor( id, postType, postId, settings, overridePost ) const target = document.getElementById( id ); const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost ); + // Global deprecations which cannot otherwise be injected into known usage. + deprecated( 'block `id` prop in `edit` function', { + version: '3.4', + alternative: 'block `clientId` prop', + plugin: 'Gutenberg', + hint: 'This is a global warning, shown regardless of whether blocks exist using the deprecated prop.', + } ); + registerCoreBlocks(); dispatch( 'core/nux' ).triggerGuide( [ diff --git a/editor/components/block-list/block.js b/editor/components/block-list/block.js index 710d9c5ceccd9..a8c925f031872 100644 --- a/editor/components/block-list/block.js +++ b/editor/components/block-list/block.js @@ -534,6 +534,7 @@ export class BlockListBlock extends Component { insertBlocksAfter={ isLocked ? undefined : this.insertBlocksAfter } onReplace={ isLocked ? undefined : onReplace } mergeBlocks={ isLocked ? undefined : this.mergeBlocks } + clientId={ uid } id={ uid } isSelectionEnabled={ this.props.isSelectionEnabled } toggleSelection={ this.props.toggleSelection }