diff --git a/packages/block-editor/src/components/link-control/use-internal-input-value.js b/packages/block-editor/src/components/link-control/use-internal-input-value.js index 99dd5a7168a94..5dd3c59f3e873 100644 --- a/packages/block-editor/src/components/link-control/use-internal-input-value.js +++ b/packages/block-editor/src/components/link-control/use-internal-input-value.js @@ -1,12 +1,23 @@ /** * WordPress dependencies */ -import { useState } from '@wordpress/element'; +import { useState, useEffect } from '@wordpress/element'; export default function useInternalInputValue( value ) { const [ internalInputValue, setInternalInputValue ] = useState( value || '' ); + // If the value prop changes, update the internal state. + useEffect( () => { + setInternalInputValue( ( prevValue ) => { + if ( value && value !== prevValue ) { + return value; + } + + return prevValue; + } ); + }, [ value ] ); + return [ internalInputValue, setInternalInputValue ]; }