Refactor URLInput
to remove requirement for Promise in fetchSuggestions
#19526
Labels
[Feature] Link Editing
Link components (LinkControl, URLInput) and integrations (RichText link formatting)
[Package] Block editor
/packages/block-editor
[Type] Code Quality
Issues or PRs that relate to code quality
Currently
URLInput
requires that, when called,__experimentalFetchLinkSuggestions
return aPromise
which resolves with the search suggestion results.However, this causes some technical debt and inelegant code to be required by components that consume
URLInput
. For exampleLinkControl
uses the__experimentalFetchLinkSuggestions
to provide results for direct URL entry. In doing so it is forced to return aPromise
even though the results themselves have no need of async fetching.To solve this we should make the
updateSuggestions
method ofURLInput
handle values even if they are not Promises. This shoulld be as simple as wrapping the result of calling__experimentalFetchLinkSuggestions()
withPromise.resolve()
:The text was updated successfully, but these errors were encountered: