Skip to content

Commit

Permalink
Block API: Deprecate id prop in favor of clientId (#7669)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jul 10, 2018
1 parent d574792 commit a5d7295
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Popover focusOnMount />` usage to `<Popover focusOnMount="firstElement" />`.
- `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

Expand Down
9 changes: 9 additions & 0 deletions edit-post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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( [
Expand Down
1 change: 1 addition & 0 deletions editor/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit a5d7295

Please sign in to comment.