diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js
index 4d1ddea8c93fb..df00d0c10c067 100644
--- a/packages/block-library/src/search/edit.js
+++ b/packages/block-library/src/search/edit.js
@@ -54,6 +54,7 @@ import {
MIN_WIDTH,
isPercentageUnit,
} from './utils.js';
+import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
// Used to calculate border radius adjustment to avoid "fat" corners when
// button is placed inside wrapper.
@@ -370,6 +371,7 @@ export default function SearchEdit( {
>
);
};
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
const controls = (
<>
@@ -416,21 +418,26 @@ export default function SearchEdit( {
widthUnit: undefined,
} );
} }
+ dropdownMenuProps={ dropdownMenuProps }
>
!! width }
+ hasValue={ () =>
+ PERCENTAGE_WIDTHS.includes( width ) &&
+ widthUnit === '%'
+ }
label={ __( 'Width' ) }
- resetAll={ () =>
+ resetAll={ () => {
setAttributes( {
- width: undefined,
- } )
- }
+ width: PC_WIDTH_DEFAULT, // Reset to default value
+ widthUnit: undefined,
+ } );
+ } }
isShownByDefault
>
{
setAttributes( {
width:
- '%' === newUnit
+ newUnit === '%'
? PC_WIDTH_DEFAULT
: PX_WIDTH_DEFAULT,
widthUnit: newUnit,
} );
} }
__unstableInputWidth="80px"
- value={ `${ width }${ widthUnit }` }
+ value={
+ width ? `${ width }${ widthUnit || '' }` : ''
+ }
units={ units }
+ style={ { marginBottom: '16px' } }
/>
-
-
- PERCENTAGE_WIDTHS.includes( width ) &&
- widthUnit === '%'
- }
- label={ __( 'Percentage Width' ) }
- resetAll={ () =>
- setAttributes( {
- width: undefined,
- widthUnit: undefined,
- } )
- }
- isShownByDefault
- >