LinkControl: prepend https:// to URLs submitted without selecting sug...#76303
LinkControl: prepend https:// to URLs submitted without selecting sug...#76303Br1an67 wants to merge 1 commit intoWordPress:trunkfrom
Conversation
…gestions When users type a URL like "wordpress.org" or "www.wordpress.org" and press Enter without selecting from the dropdown, the URL was saved without a protocol. This fix normalizes the URL using the existing normalizeUrl function to prepend "https://" to bare domains, matching the behavior when selecting suggestions from the dropdown.
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Br1an67. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Br1an67! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
@jeryj I had thought we'd addressed this requirement to default to |
|
@getdave - I think this issue was already fixed on trunk by #75488. @Br1an67 - thanks for contributing!
Did you encounter this bug on trunk? In my testing pressing Enter when submitting wordpress.org or www.wordpress.org results in https:// being appended. If you encountered it, can you list the reproduction steps? |
f55033b to
95929df
Compare
Fixes #75374
What?
This PR fixes an issue in LinkControl where URLs typed without a protocol (e.g.,
wordpress.orgorwww.wordpress.org) and submitted by pressing Enter (without selecting from the dropdown) were saved without thehttps://protocol.Why?
URLs without protocols are invalid and won't work as links. The existing behavior was inconsistent:
https://prepended ✅This created a confusing UX where users had to remember to select from the dropdown to get properly formatted URLs.
How?
The fix imports the existing
normalizeUrlfunction (which already handles prependinghttps://to bare domains) and uses it in theonSubmithandler ofsearch-input.jswhen creating a direct entry suggestion object.Change made:
packages/block-editor/src/components/link-control/search-input.js: ImportnormalizeUrland use it to normalize the URL value when submitting without a suggestionTesting Instructions
wordpress.orgorwww.wordpress.org)https://prepended (e.g.,https://wordpress.org)Testing Instructions for Keyboard
example.comand press Enterhttps://example.comScreenshots
wordpress.org(broken link)https://wordpress.org(working link)