@@ -9,6 +9,8 @@ import classnames from 'classnames';
99import { Button , Spinner , Notice } from '@wordpress/components' ;
1010import { __ } from '@wordpress/i18n' ;
1111import { useRef , useState , useEffect } from '@wordpress/element' ;
12+ import { select , dispatch } from '@wordpress/data' ;
13+ import { store as preferencesStore } from '@wordpress/preferences' ;
1214import { focus } from '@wordpress/dom' ;
1315import { ENTER } from '@wordpress/keycodes' ;
1416
@@ -136,7 +138,14 @@ function LinkControl( {
136138 const textInputRef = useRef ( ) ;
137139 const isEndingEditWithFocus = useRef ( false ) ;
138140
139- const [ settingsOpen , setSettingsOpen ] = useState ( false ) ;
141+ const isSettingsOpen = select ( preferencesStore ) . get (
142+ 'core/editor' ,
143+ 'linkControlSettingsOpen'
144+ ) ;
145+
146+ const [ settingsOpen , setSettingsOpen ] = useState (
147+ isSettingsOpen || false
148+ ) ;
140149
141150 const [ internalUrlInputValue , setInternalUrlInputValue ] =
142151 useInternalInputValue ( value ?. url || '' ) ;
@@ -192,6 +201,14 @@ function LinkControl( {
192201 isEndingEditWithFocus . current = false ;
193202 } , [ isEditingLink , isCreatingPage ] ) ;
194203
204+ useEffect ( ( ) => {
205+ dispatch ( preferencesStore ) . set (
206+ 'core/editor' ,
207+ 'linkControlSettingsOpen' ,
208+ settingsOpen
209+ ) ;
210+ } , [ settingsOpen ] ) ;
211+
195212 const hasLinkValue = value ?. url ?. trim ( ) ?. length > 0 ;
196213
197214 /**
0 commit comments