Skip to content

Commit

Permalink
Fix focus loss when creating pages from link control search results (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Apr 15, 2022
1 parent e853724 commit 731d178
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ function LinkControl( {

const currentInputIsEmpty = ! currentInputValue?.trim()?.length;

const { createPage, isCreatingPage, errorMessage } = useCreatePage(
createSuggestion
);

useEffect( () => {
if (
forceIsEditingLink !== undefined &&
Expand Down Expand Up @@ -185,7 +189,7 @@ function LinkControl( {
nextFocusTarget.focus();

isEndingEditWithFocus.current = false;
}, [ isEditingLink ] );
}, [ isEditingLink, isCreatingPage ] );

useEffect( () => {
/**
Expand Down Expand Up @@ -217,10 +221,6 @@ function LinkControl( {
setIsEditingLink( false );
}

const { createPage, isCreatingPage, errorMessage } = useCreatePage(
createSuggestion
);

const handleSelectSuggestion = ( updatedValue ) => {
onChange( {
...updatedValue,
Expand Down

0 comments on commit 731d178

Please sign in to comment.