diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js index 1cc7484502571e..e279fcb0ad002b 100644 --- a/packages/block-library/src/search/edit.js +++ b/packages/block-library/src/search/edit.js @@ -15,9 +15,7 @@ import { __experimentalUnitControl as UnitControl, } from '@wordpress/block-editor'; import { - DropdownMenu, - MenuGroup, - MenuItem, + ToolbarDropdownMenu, ToolbarGroup, Button, ButtonGroup, @@ -115,6 +113,42 @@ export default function SearchEdit( { ); }; + const buttonPositionControls = [ + { + role: 'menuitemradio', + title: __( 'Button outside' ), + isActive: buttonPosition === 'button-outside', + icon: buttonOutside, + onClick: () => { + setAttributes( { + buttonPosition: 'button-outside', + } ); + }, + }, + { + role: 'menuitemradio', + title: __( 'Button inside' ), + isActive: buttonPosition === 'button-inside', + icon: buttonInside, + onClick: () => { + setAttributes( { + buttonPosition: 'button-inside', + } ); + }, + }, + { + role: 'menuitemradio', + title: __( 'No button' ), + isActive: buttonPosition === 'no-button', + icon: noButton, + onClick: () => { + setAttributes( { + buttonPosition: 'no-button', + } ); + }, + }, + ]; + const getButtonPositionIcon = () => { switch ( buttonPosition ) { case 'button-inside': @@ -201,49 +235,11 @@ export default function SearchEdit( { } } className={ showLabel ? 'is-pressed' : undefined } /> - - { ( { onClose } ) => ( - - { - setAttributes( { - buttonPosition: 'no-button', - } ); - onClose(); - } } - > - { __( 'No Button' ) } - - { - setAttributes( { - buttonPosition: 'button-outside', - } ); - onClose(); - } } - > - { __( 'Button Outside' ) } - - { - setAttributes( { - buttonPosition: 'button-inside', - } ); - onClose(); - } } - > - { __( 'Button Inside' ) } - - - ) } - - + controls={ buttonPositionControls } + /> { 'no-button' !== buttonPosition && (