Open external links in a new tab or window

Created on 21 June 2022, about 2 years ago
Updated 25 March 2024, 3 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 work

Version

1.0

Component

General code

Created by

🇺🇸United States choicelildice

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

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

Production build 0.69.0 2024