diff --git a/packages/components/src/unit-control/utils.js b/packages/components/src/unit-control/utils.js index afe41d9bc39bf..238f1e9cdcdda 100644 --- a/packages/components/src/unit-control/utils.js +++ b/packages/components/src/unit-control/utils.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { isEmpty } from 'lodash'; +import { isEmpty, keyBy } from 'lodash'; export const CSS_UNITS = [ { value: 'px', label: 'px', default: 0 }, @@ -61,7 +61,7 @@ export function parseUnit( initialValue, units = CSS_UNITS ) { unit = unit.toLowerCase(); if ( hasUnits( units ) ) { - const match = units.find( ( item ) => item.value === unit ); + const match = keyBy( units, 'value' )[ unit ]; unit = match?.value; }