diff --git a/packages/block-editor/src/components/link-control/use-search-handler.js b/packages/block-editor/src/components/link-control/use-search-handler.js index 455d228be1974..80cef60f6329b 100644 --- a/packages/block-editor/src/components/link-control/use-search-handler.js +++ b/packages/block-editor/src/components/link-control/use-search-handler.js @@ -17,8 +17,7 @@ import { URL_TYPE, } from './constants'; import { store as blockEditorStore } from '../../store'; - -export const handleNoop = () => Promise.resolve( [] ); +import { default as settingsKeys } from '../../private-settings-keys'; export const handleDirectEntry = ( val ) => { let type = URL_TYPE; @@ -47,103 +46,65 @@ export const handleDirectEntry = ( val ) => { ] ); }; -const handleEntitySearch = async ( - val, - suggestionsQuery, - fetchSearchSuggestions, - withCreateSuggestion, - pageOnFront, - pageForPosts -) => { - const { isInitialSuggestions } = suggestionsQuery; - - const results = await fetchSearchSuggestions( val, suggestionsQuery ); - - // Identify front page and update type to match. - results.map( ( result ) => { - if ( Number( result.id ) === pageOnFront ) { - result.isFrontPage = true; - return result; - } else if ( Number( result.id ) === pageForPosts ) { - result.isBlogHome = true; - return result; - } - - return result; - } ); - - // If displaying initial suggestions just return plain results. - if ( isInitialSuggestions ) { - return results; - } - - // Here we append a faux suggestion to represent a "CREATE" option. This - // is detected in the rendering of the search results and handled as a - // special case. This is currently necessary because the suggestions - // dropdown will only appear if there are valid suggestions and - // therefore unless the create option is a suggestion it will not - // display in scenarios where there are no results returned from the - // API. In addition promoting CREATE to a first class suggestion affords - // the a11y benefits afforded by `URLInput` to all suggestions (eg: - // keyboard handling, ARIA roles...etc). - // - // Note also that the value of the `title` and `url` properties must correspond - // to the text value of the ``. This is because `title` is used - // when creating the suggestion. Similarly `url` is used when using keyboard to select - // the suggestion (the