Skip to content

Commit

Permalink
Link Control: Fix focus handlers in development mode (WordPress#62141)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
  • Loading branch information
4 people authored and carstingaxion committed Jun 4, 2024
1 parent 5b4d30e commit ae06d85
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;

/**
Expand Down

0 comments on commit ae06d85

Please sign in to comment.