Skip to content

LinkControl: Automatically highlight first suggestion by default#71132

Open
BugReportOnWeb wants to merge 1 commit intoWordPress:trunkfrom
BugReportOnWeb:feat/link-control-item-highlight
Open

LinkControl: Automatically highlight first suggestion by default#71132
BugReportOnWeb wants to merge 1 commit intoWordPress:trunkfrom
BugReportOnWeb:feat/link-control-item-highlight

Conversation

@BugReportOnWeb
Copy link
Copy Markdown
Contributor

What?

Closes #56161

This PR ensures the first search suggestion is highlighted providing a clear feedback to the user that the first suggestion is selected by default.

Why?

Currently when a user searches for a link, no suggestion is initially highlighted, even though pressing Enter would select the first suggestion. This made it unclear which item was going to be selected by default. By highlighting the first suggestion, it gives a feedback to the user of the selected suggestion.

How?

The state of selectedSuggestion is updated in URLInput based on the previous state. If no suggestion is highlighted and the list is not empty, the first item (index 0) is selected by default.

Testing Instructions

  1. Add a text to a paragraph block.
  2. Select the text and add link to it (opens the LinkControl UI)
  3. If the list is not empty, ensure the first item is highlighted by default.
  4. Search for a term in the input box
  5. Observe the first item stays highlighted.
  6. Use arrow keys to navigate between suggestions.
  7. Ensure the highlighted item changes on keyboard action (up/down)

Screenshots or screencast

Before After
Screenshot 2025-08-08 at 1 19 55 PM Screenshot 2025-08-08 at 1 22 36 PM

@BugReportOnWeb BugReportOnWeb marked this pull request as ready for review August 8, 2025 08:32
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 8, 2025

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: BugReportOnWeb <devasheeshkaul@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>

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

@yogeshbhutkar yogeshbhutkar added [Type] Enhancement A suggestion for improvement. [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Aug 8, 2025
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) [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link Control: Default "enter" to select the first item in the list

2 participants