From 042559c0ff20adda33b0017a25c909b09529c335 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 30 May 2024 16:31:15 +0400 Subject: [PATCH] Link Control: Fix focus handlers in development mode --- .../block-editor/src/components/link-control/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/link-control/index.js b/packages/block-editor/src/components/link-control/index.js index 053839c86996d..576556519fb2f 100644 --- a/packages/block-editor/src/components/link-control/index.js +++ b/packages/block-editor/src/components/link-control/index.js @@ -220,7 +220,6 @@ function LinkControl( { // because otherwise using the keyboard to select text // *within* the link format is not possible. if ( isMounting.current ) { - isMounting.current = false; return; } @@ -238,6 +237,16 @@ function LinkControl( { isEndingEditWithFocus.current = false; }, [ isEditingLink, isCreatingPage ] ); + // The component mounting reference is maintained separately + // to correctly reset values in `StrictMode`. + useEffect( () => { + isMounting.current = false; + + return () => { + isMounting.current = true; + }; + }, [] ); + const hasLinkValue = value?.url?.trim()?.length > 0; /**