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

Add arrow navigation to Warning dropdown menu #24333

Merged
merged 3 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 16 additions & 14 deletions packages/block-editor/src/components/warning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { Children } from '@wordpress/element';
import { Dropdown, Button, MenuGroup, MenuItem } from '@wordpress/components';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreHorizontal } from '@wordpress/icons';

/**
* Internal dependencies
*/
import BlockIcon from '../block-icon';

function Warning( { className, actions, children, secondaryActions } ) {
return (
<div className={ classnames( className, 'block-editor-warning' ) }>
Expand All @@ -29,19 +34,16 @@ function Warning( { className, actions, children, secondaryActions } ) {
</span>
) ) }
{ secondaryActions && (
<Dropdown
<DropdownMenu
className="block-editor-warning__secondary"
contentClassName="block-editor-warning__dropdown"
position="bottom left"
renderToggle={ ( { isOpen, onToggle } ) => (
<Button
icon={ moreHorizontal }
label={ __( 'More options' ) }
onClick={ onToggle }
aria-expanded={ isOpen }
/>
) }
renderContent={ () => (
icon={ <BlockIcon icon={ moreHorizontal } /> }
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
label={ __( 'More options' ) }
popoverProps={ {
position: 'bottom left',
className: 'block-editor-warning__dropdown',
} }
>
{ () => (
<MenuGroup>
{ secondaryActions.map(
( item, pos ) => (
Expand All @@ -55,7 +57,7 @@ function Warning( { className, actions, children, secondaryActions } ) {
) }
</MenuGroup>
) }
/>
</DropdownMenu>
) }
</div>
) }
Expand Down
3 changes: 3 additions & 0 deletions packages/block-editor/src/components/warning/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@
// Set z-index as if it's displayed on the bottom, otherwise the modal
// dialog popover might overlap if displayed on the bottom.
z-index: z-index(".components-popover.block-editor-warning__dropdown");
.components-menu-item__button {
padding: 6px 12px;
ntsekouras marked this conversation as resolved.
Show resolved Hide resolved
}
}