Skip to content

Commit 78a4f34

Browse files
committed
feat(link-control): keep the setting opened
1 parent 68ce88b commit 78a4f34

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/block-editor/src/components/link-control/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import classnames from 'classnames';
99
import { Button, Spinner, Notice } from '@wordpress/components';
1010
import { __ } from '@wordpress/i18n';
1111
import { useRef, useState, useEffect } from '@wordpress/element';
12+
import { select, dispatch } from '@wordpress/data';
13+
import { store as preferencesStore } from '@wordpress/preferences';
1214
import { focus } from '@wordpress/dom';
1315
import { 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

Comments
 (0)