Skip to content

Commit

Permalink
disable button when open
Browse files Browse the repository at this point in the history
  • Loading branch information
Addison-Stavlo committed Sep 9, 2020
1 parent eb3ff1d commit e2d7e04
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/block-library/src/template-part/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
BlockControls,
__experimentalBlock as Block,
} from '@wordpress/block-editor';
import { Dropdown, Button } from '@wordpress/components';
import { Dropdown, ToolbarButton } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { chevronUp, chevronDown } from '@wordpress/icons';

Expand Down Expand Up @@ -81,11 +81,14 @@ export default function TemplatePartEdit( {
contentClassName="wp-block-template-part__preview-dropdown-content"
position="bottom right left"
renderToggle={ ( { isOpen, onToggle } ) => (
<Button
label={ __( 'Choose another' ) }
onClick={ onToggle }
<ToolbarButton
aria-expanded={ isOpen }
icon={ isOpen ? chevronUp : chevronDown }
label={ __( 'Choose another' ) }
onClick={ onToggle }
// Disable when open to prevent odd FireFox bug causing reopening.
// As noted in https://github.com/WordPress/gutenberg/pull/24990#issuecomment-689094119 .
disabled={ isOpen }
/>
) }
renderContent={ ( { onClose } ) => (
Expand Down

0 comments on commit e2d7e04

Please sign in to comment.