"`;
+exports[`Basic rendering should render 1`] = `"
"`;
exports[`Rich link previews should display a rich preview when data is available 1`] = `
.emotion-2 {
diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js
index d015267a8e38f7..c0098b1393758d 100644
--- a/packages/format-library/src/link/inline.js
+++ b/packages/format-library/src/link/inline.js
@@ -11,6 +11,7 @@ import {
isCollapsed,
applyFormat,
useAnchorRef,
+ removeFormat,
} from '@wordpress/rich-text';
import { __experimentalLinkControl as LinkControl } from '@wordpress/block-editor';
@@ -49,6 +50,15 @@ function InlineLinkUI( {
};
function onChangeLink( nextValue ) {
+ // null values trigger removal of link format.
+ if ( null === nextValue ) {
+ const newValue = removeFormat( value, 'core/link' );
+ onChange( newValue );
+ stopAddingLink();
+ speak( __( 'Link removed.' ), 'assertive' );
+ return;
+ }
+
// Merge with values from state, both for the purpose of assigning the
// next state value, and for use in constructing the new link format if
// the link is ready to be applied.