Skip to content

LinkControl: prepend https:// to URLs submitted without selecting sug...#76303

Open
Br1an67 wants to merge 1 commit intoWordPress:trunkfrom
Br1an67:fix/issue-75374-linkcontrol-https
Open

LinkControl: prepend https:// to URLs submitted without selecting sug...#76303
Br1an67 wants to merge 1 commit intoWordPress:trunkfrom
Br1an67:fix/issue-75374-linkcontrol-https

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 9, 2026

Fixes #75374

What?

This PR fixes an issue in LinkControl where URLs typed without a protocol (e.g., wordpress.org or www.wordpress.org) and submitted by pressing Enter (without selecting from the dropdown) were saved without the https:// protocol.

Why?

URLs without protocols are invalid and won't work as links. The existing behavior was inconsistent:

  • Selecting a suggestion from dropdown: URL gets https:// prepended ✅
  • Pressing Enter directly: URL stays as-is without protocol ❌

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 normalizeUrl function (which already handles prepending https:// to bare domains) and uses it in the onSubmit handler of search-input.js when creating a direct entry suggestion object.

Change made:

  • packages/block-editor/src/components/link-control/search-input.js: Import normalizeUrl and use it to normalize the URL value when submitting without a suggestion

Testing Instructions

  1. Add a Navigation block to a post or page
  2. Add a link and type a URL without a protocol (e.g., wordpress.org or www.wordpress.org)
  3. Press Enter without selecting from the dropdown
  4. Verify the URL is saved with https:// prepended (e.g., https://wordpress.org)

Testing Instructions for Keyboard

  1. Navigate to a Navigation block using keyboard (Tab)
  2. Add a new link item
  3. Type example.com and press Enter
  4. Verify the link works correctly with https://example.com

Screenshots

Before After
URL saved as wordpress.org (broken link) URL saved as https://wordpress.org (working link)

…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.
@Br1an67 Br1an67 requested a review from getdave as a code owner March 9, 2026 02:45
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

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.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block editor, First-time Contributor.

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.

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

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 props-bot label.

Unlinked Accounts

The 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.

Unlinked contributors: Br1an67.

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the [Package] Block editor /packages/block-editor label Mar 9, 2026
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 9, 2026
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

👋 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.

@getdave getdave requested a review from jeryj March 9, 2026 13:37
@getdave
Copy link
Contributor

getdave commented Mar 9, 2026

@jeryj I had thought we'd addressed this requirement to default to https://?

@jeryj
Copy link
Contributor

jeryj commented Mar 9, 2026

@getdave - I think this issue was already fixed on trunk by #75488.

@Br1an67 - thanks for contributing!

This PR fixes an issue in LinkControl where URLs typed without a protocol (e.g., wordpress.org or www.wordpress.org) and submitted by pressing Enter (without selecting from the dropdown) were saved without the https:// protocol.

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?

@Br1an67 Br1an67 force-pushed the fix/issue-75374-linkcontrol-https branch from f55033b to 95929df Compare March 18, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkControl doesn't prepend https:// when submitting URLs without selecting suggestions

3 participants