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

Update/menu item #14423

Merged
merged 3 commits into from
Mar 22, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function BlockConvertButton( { shouldRender, onClick, small } ) {
className="editor-block-settings-menu__control"
onClick={ onClick }
icon="screenoptions"
label={ small ? label : undefined }
>
{ ! small && label }
</MenuItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function BlockModeToggle( { blockType, mode, onToggleMode, small = false
className="editor-block-settings-menu__control"
onClick={ onToggleMode }
icon="html"
label={ small ? label : undefined }
>
{ ! small && label }
</MenuItem>
Expand Down
9 changes: 0 additions & 9 deletions packages/components/src/menu-item/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ Element to render as child of button.

Element

### `label`

- Type: `string`
- Required: No

String to use as primary button label text, applied as `aria-label`. Useful in cases where an `info` prop is passed, where `label` should be the minimal text of the button, described in further detail by `info`.

Defaults to the value of `children`, if `children` is passed as a string.

### `info`

- Type: `string`
Expand Down
7 changes: 0 additions & 7 deletions packages/components/src/menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,17 @@ export function MenuItem( {
shortcut,
isSelected,
role = 'menuitem',
instanceId,
...props
} ) {
className = classnames( 'components-menu-item__button', className, {
'has-icon': icon,
} );

if ( info ) {
const infoId = 'edit-post-feature-toggle__info-' + instanceId;

// Deconstructed props is scoped to the function; mutation is fine.
props[ 'aria-describedby' ] = infoId;

children = (
<span className="components-menu-item__info-wrapper">
{ children }
<span
id={ infoId }
className="components-menu-item__info">
{ info }
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ exports[`MenuItem should match snapshot when all props provided 1`] = `

exports[`MenuItem should match snapshot when info is provided 1`] = `
<ForwardRef(Button)
aria-describedby="edit-post-feature-toggle__info-1"
className="components-menu-item__button"
role="menuitem"
>
Expand All @@ -28,7 +27,6 @@ exports[`MenuItem should match snapshot when info is provided 1`] = `
My item
<span
className="components-menu-item__info"
id="edit-post-feature-toggle__info-1"
>
Extended description of My Item
</span>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/menu-item/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe( 'MenuItem', () => {

it( 'should match snapshot when info is provided', () => {
const wrapper = shallow(
<MenuItem info="Extended description of My Item" instanceId={ 1 }>
<MenuItem info="Extended description of My Item">
My item
</MenuItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function FeatureToggle( { onToggle, isActive, label, info, messageActivated, mes
isSelected={ isActive }
onClick={ flow( onToggle, speakMessage ) }
role="menuitemcheckbox"
label={ label }
info={ info }
>
{ label }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports[`PluginMoreMenuItem renders menu item as button properly 1`] = `
>
<button
className="components-button components-icon-button components-menu-item__button has-icon has-text"
instanceId={0}
onClick={[Function]}
role="menuitem"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export function BlockInspectorButton( {
className="editor-block-settings-menu__control"
onClick={ flow( areAdvancedSettingsOpened ? closeSidebar : openEditorSidebar, speakMessage, onClick ) }
icon="admin-generic"
label={ small ? label : undefined }
shortcut={ shortcuts.toggleSidebar }
>
{ ! small && label }
Expand Down