Skip to content

Refactor URLInput to remove requirement for Promise in fetchSuggestions #19526

@getdave

Description

@getdave

Currently URLInput requires that, when called, __experimentalFetchLinkSuggestions return a Promise 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 example LinkControl uses the __experimentalFetchLinkSuggestions to provide results for direct URL entry. In doing so it is forced to return a Promise even though the results themselves have no need of async fetching.

To solve this we should make the updateSuggestions method of URLInput handle values even if they are not Promises. This shoulld be as simple as wrapping the result of calling __experimentalFetchLinkSuggestions() with Promise.resolve():

Promise.resolve(__experimentalFetchLinkSuggestions).then()

Metadata

Metadata

Assignees

Labels

[Feature] Link EditingLink components (LinkControl, URLInput) and integrations (RichText link formatting)[Package] Block editor/packages/block-editor[Type] Code QualityIssues or PRs that relate to code quality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions