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
Prev Previous commit
Next Next commit
Fix mutating prop in new PresetInputControl
  • Loading branch information
aaronrobertshaw committed Dec 10, 2025
commit 97de20dda3b34c5d36a6c1d088793bef058e5948
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { usePrevious } from '@wordpress/compose';
import { __, sprintf } from '@wordpress/i18n';
import { settings } from '@wordpress/icons';
import { useState } from '@wordpress/element';
import { useMemo, useState } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function PresetInputControl( {
disableCustomValues,
icon,
isMixed,
value,
value: valueProp,
minimumCustomValue,
onChange,
onMouseOut,
Expand All @@ -80,8 +80,10 @@ export default function PresetInputControl( {
showTooltip,
units,
} ) {
// Treat value as a preset value if the passed in value matches the value of one of the presets.
value = getPresetValueFromCustomValue( value, presets, presetType );
const value = useMemo(
() => getPresetValueFromCustomValue( valueProp, presets, presetType ),
[ valueProp, presets, presetType ]
);

const className = classNameProp ?? 'preset-input-control';

Expand Down