Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor URLInput to remove requirement for Promise in fetchSuggestions #19526

Open
Tracked by #35073
getdave opened this issue Jan 9, 2020 · 1 comment
Open
Tracked by #35073
Assignees
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

Comments

@getdave
Copy link
Contributor

getdave commented Jan 9, 2020

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()
@getdave getdave self-assigned this Jan 9, 2020
@getdave
Copy link
Contributor Author

getdave commented Jan 9, 2020

Implementing this sholuld probably wait on #19458 as otherwise there will be some nasty rebases required.

@talldan talldan added [Package] Block editor /packages/block-editor [Type] Code Quality Issues or PRs that relate to code quality labels Feb 5, 2020
@skorasaurus skorasaurus added the [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) label Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants