From a4a0927a0f3bb9a53403c791e989d1c6ba4eaaf9 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 10 Jan 2024 09:41:39 +0000 Subject: [PATCH] Close the Link UI on value updates except upon initial creation --- packages/format-library/src/link/inline.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js index ca9bdfd6d1734d..3b540d7970afb4 100644 --- a/packages/format-library/src/link/inline.js +++ b/packages/format-library/src/link/inline.js @@ -89,6 +89,9 @@ function InlineLinkUI( { } function onChangeLink( nextValue ) { + const hasLink = linkValue?.url; + const isNewLink = ! hasLink; + // Merge the next value with the current link value. nextValue = { ...linkValue, @@ -173,7 +176,11 @@ function InlineLinkUI( { newValue.start = newValue.end; - // Hides the Link UI. + // Hides the Link UI on change except upon the initial creation of the link. + if ( ! isNewLink ) { + newValue.activeFormats = []; + } + onChange( newValue ); }