Skip to content

Commit

Permalink
Ensures the input field stays in sync with color changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvikpatel18 committed Feb 19, 2025
1 parent 1c78ef7 commit 605f706
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/components/src/color-palette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function CustomColorValueInput( {
const inputRef = useRef< HTMLInputElement >( null );
const truncateRef = useRef< HTMLDivElement >( null );

useEffect( () => {
setInputValue( value );
}, [ value ] );

useEffect( () => {
if ( isEditing && inputRef.current ) {
inputRef.current.focus();
Expand Down Expand Up @@ -111,6 +115,7 @@ function CustomColorValueInput( {
if ( isEditing && isHex ) {
return (
<input
ref={ inputRef }
type="text"
value={ inputValue || '' }
onChange={ handleChange }
Expand Down

0 comments on commit 605f706

Please sign in to comment.