Skip to content

Commit

Permalink
Search block: Fix width input field (#53952)
Browse files Browse the repository at this point in the history
  • Loading branch information
Petter Walbø Johnsgård committed Aug 30, 2023
1 parent cd5d5fe commit 0ae22b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/block-library/src/search/edit.js
Expand Up @@ -52,7 +52,7 @@ import {
PC_WIDTH_DEFAULT,
PX_WIDTH_DEFAULT,
MIN_WIDTH,
MIN_WIDTH_UNIT,
isPercentageUnit,
} from './utils.js';

// Used to calculate border radius adjustment to avoid "fat" corners when
Expand Down Expand Up @@ -405,7 +405,13 @@ export default function SearchEdit( {
>
<UnitControl
id={ unitControlInputId }
min={ `${ MIN_WIDTH }${ MIN_WIDTH_UNIT }` }
min={
isPercentageUnit( widthUnit ) ? 0 : MIN_WIDTH
}
max={
isPercentageUnit( widthUnit ) ? 100 : undefined
}
step={ 1 }
onChange={ ( newWidth ) => {
const filteredWidth =
widthUnit === '%' &&
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/search/utils.js
Expand Up @@ -4,7 +4,6 @@
export const PC_WIDTH_DEFAULT = 50;
export const PX_WIDTH_DEFAULT = 350;
export const MIN_WIDTH = 220;
export const MIN_WIDTH_UNIT = 'px';

/**
* Returns a boolean whether passed unit is percentage
Expand Down

0 comments on commit 0ae22b5

Please sign in to comment.