Your value
prop is the wrong format. From <LinkControl>
‘s README:
value
- Type:
Object
- Required: No
Current link value.
A link
value
is composed of a union between the values of default link properties and any custom linksettings
.The resulting default properties of
value
include:
url
(string
): Link URL.title
(string
, optional): Link title.opensInNewTab
(boolean
, optional): Whether link should open in a new browser tab. This value is only assigned when not providing a customsettings
prop.
If the link’s actual title & “opensInNewTab” properties are relevant to your ends, then you should store the whole value in attributes in the handleLinkChange()
function. Otherwise, specifying the linkText
attribute should be sufficient. As mentioned in the README, you can also specify a settings
prop to suppress the “Opens in New Tab” toggle (or add additional toggles):
<LinkControl
onChange={ handleLinkChange }
value={ { url: linkURL, title: linkText } }
settings={ [] }
/>