Skip to content

Commit

Permalink
Add CHANGELOG entries and deprecations messages for update props
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Aug 8, 2019
1 parent 3429cc3 commit 46bef32
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Expand Up @@ -11,6 +11,10 @@ import { orderBy } from 'lodash';
import { __ } from '@wordpress/i18n';
import { Toolbar, Slot, DropdownMenu } from '@wordpress/components';

const POPOVER_PROPS = {
position: 'bottom left',
};

const FormatToolbar = () => {
return (
<div className="editor-format-toolbar block-editor-format-toolbar">
Expand All @@ -22,9 +26,9 @@ const FormatToolbar = () => {
{ ( fills ) => fills.length !== 0 &&
<DropdownMenu
icon={ false }
position="bottom left"
label={ __( 'More Rich Text Controls' ) }
controls={ orderBy( fills.map( ( [ { props } ] ) => props ), 'title' ) }
popoverProps={ POPOVER_PROPS }
/>
}
</Slot>
Expand Down
10 changes: 9 additions & 1 deletion packages/components/CHANGELOG.md
Expand Up @@ -2,8 +2,16 @@

### New Features

- Added a new `popoverProps` prop to the `Dropdown` component which allows users of the `Dropdown` component to pass props directly to the `PopOver` component.
- Added a new `popoverProps` prop to the `Dropdown` component which allows users of the `Dropdown` component to pass props directly to the `Popover` component.
- Added and documented `hideLabelFromVision` prop to `BaseControl` used by `SelectControl`, `TextControl`, and `TextareaControl`.
- Added a new `popoverProps` prop to the `DropdownMenu` component which allows to pass props directly to the nested `Popover` component.
- Added a new `toggleProps` prop to the `DropdownMenu` component which allows to pass props directly to the nested `IconButton` component.
- Added a new `menuProps` prop to the `DropdownMenu` component which allows to pass props directly to the nested `NavigableMenu` component.

### Deprecations

- `menuLabel` prop in `DropdownComponent` has been deprecated. Consider using `menuProps` object and its `aria-label` property instead.
- `position` prop in `DropdownComponent` has been deprecated. Consider using `popoverProps` object and its `position` property instead.

### Bug Fixes

Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/dropdown-menu/index.js
Expand Up @@ -8,6 +8,7 @@ import { flatMap, isEmpty, isFunction } from 'lodash';
* WordPress dependencies
*/
import { DOWN } from '@wordpress/keycodes';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,6 +44,20 @@ function DropdownMenu( {
menuLabel,
position,
} ) {
if ( menuLabel ) {
deprecated( '`menuLabel` prop in `DropdownComponent`', {
alternative: '`menuProps` object and its `aria-label` property',
plugin: 'Gutenberg',
} );
}

if ( position ) {
deprecated( '`position` prop in `DropdownComponent`', {
alternative: '`popoverProps` object and its `position` property',
plugin: 'Gutenberg',
} );
}

if ( isEmpty( controls ) && ! isFunction( children ) ) {
return null;
}
Expand Down Expand Up @@ -76,6 +91,7 @@ function DropdownMenu( {
className: classnames( 'components-dropdown-menu__toggle', {
'is-opened': isOpen,
} ),
tooltip: label,
} );

return (
Expand Down
Expand Up @@ -41,6 +41,7 @@ exports[`MoreMenu should match snapshot 1`] = `
labelPosition="bottom"
onClick={[Function]}
onKeyDown={[Function]}
tooltip="More tools & options"
>
<Tooltip
position="bottom"
Expand Down

0 comments on commit 46bef32

Please sign in to comment.