Open external links in a new tab or window

Created on 21 June 2022, over 2 years ago
Updated 21 March 2024, 10 months ago

Problem/Motivation

If the suggestion is a link, and the link is external, we should open the link in a new tab or window.

Steps to reproduce

Pass an external link as the URL for autocomplete suggestions using search_api_autocomplete_suggestions_alter. Check the search API autocomplete results, and see that the external link opens in the same window.

Proposed resolution

Check in PHP (AutocompleteController.php) to see if the URL is external, and if so, let the Javascript know with a variable in the matches array.

Remaining tasks

Test the patch.

User interface changes

None.

API changes

None.

Data model changes

Changing the matches array that is passed to JS to let the JS code know that the link is external.

Feature request
Status

Needs review

Version

1.0

Component

General code

Created by

🇺🇸United States choicelildice

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    Thanks for suggesting this feature, and sorry for the long delay!
    I don’t think it is a universal requirement that external links should open in a new tab. Therefore, this would definitely need to be an option in the UI.
    Also, there doesn’t seem to be much demand for this feature, so I’d first wait whether there is even any interest in this being added before proceeding to implement the config form.

  • First commit to issue fork.
  • Status changed to Needs work 10 months ago
  • 🇦🇹Austria drunken monkey Vienna, Austria

    NW for adding an option and the tests.
    As said, though, I think we should first wait whether there is enough interest.

  • 🇺🇸United States spicy.werewolf

    spicy.werewolf made their first commit to this issue’s fork.

  • Merge request !36Resolves 3291751 → (Open) created by Unnamed author
  • Pipeline finished with Failed
    25 days ago
    Total: 241s
    #367037
  • Pipeline finished with Success
    25 days ago
    Total: 181s
    #367045
  • Pipeline finished with Success
    25 days ago
    Total: 213s
    #367049
  • Pipeline finished with Success
    25 days ago
    Total: 185s
    #367083
  • 🇺🇸United States choicelildice

    I updated the code to work with the latest version. Mostly because we still have a site using it.

Production build 0.71.5 2024