Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,18 @@ export default function PresetInputControl( {
unitConfig?.max ?? customValueSettings[ computedUnit ]?.max ?? 10;

const handleCustomValueChange = ( newValue ) => {
const isNumeric = ! isNaN( parseFloat( newValue ) );
const newCustomValue = isNumeric ? newValue : undefined;
const isExplicitlyEmpty = newValue === '';
const isNumeric =
newValue !== undefined && ! isNaN( parseFloat( newValue ) );

let newCustomValue;
if ( isExplicitlyEmpty ) {
newCustomValue = '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing this through to onChange will result in empty string values in the block attributes persisted in the block comment delimiter. It would be best if we can fix this bug without doing this.

} else if ( isNumeric ) {
newCustomValue = newValue;
} else {
newCustomValue = undefined;
}

if ( newCustomValue !== undefined ) {
onChange( newCustomValue );
Expand Down
Loading