Problem/Motivation

Since #2712951: Linkit for Link field, Linkit provides a link formatter, which is a subclass of core's LinkFormatter.
It inherits 2 settings, Add rel="nofollow" to links (rel) and Open link in new window (rel), which can be set via checkboxes. But when passing an internal link to a link field, these settings are ignored.

Steps to reproduce

Configure a link field to use Linkit's formatter. Edit a node, select an internal page as target. Check at least one of the settings mentioned above. Save the node. View the page and inspect the link field => the link contains neither the rel nor the target attribute.

Remaining tasks

Issue fork linkit-3350477

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mrshowerman created an issue. See original summary.

mrshowerman’s picture

Assigned: mrshowerman » Unassigned
Status: Active » Needs work
Issue tags: +Needs tests
StatusFileSize
new1.38 KB

Here's a first patch that brings back the attributes.
Could use some help with a test though.

mark_fullmer’s picture

Status: Needs work » Needs review
StatusFileSize
new1.26 KB

I'm not sure I'm able to reproduce the problem described in the 6.0.x branch. I've attached a patch that includes test coverage that demonstrates the the rel and target values are reflected from the Linkit Formatter settings.

mrshowerman’s picture

Status: Needs review » Closed (works as designed)
Related issues: +#2885351: Query string duplications

I had another look and it seems the issue isn't in Linkit, but related to the patch from #2885351: Query string duplications, where the link item's #options is being reset to an empty array, in order to avoid duplicate query string parameters.

Sorry for the noise; I'll take a closer look at #2885351, maybe there's a better approach than the current one.
Not sure if this is the right status; maybe the test is still useful for detecting similar issues in the future.

mark_fullmer’s picture

Title: LinkitFormatter ignores rel and target settings » Add test coverage for rel and target settings
Status: Closed (works as designed) » Needs review

Re-opening and updating the title to indicate that we can add test coverage to demonstrate this works as designed (and to flag a failure in #2885351: Query string duplications.

mmarler’s picture

Assigned: Unassigned » mmarler
mmarler’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

mmarler’s picture

Assigned: mmarler » Unassigned

  • mark_fullmer committed 274ad127 on 6.0.x
    Issue #3350477 by mrshowerman, mark_fullmer, mmarler: Add test coverage...

  • mark_fullmer committed 274ad127 on 6.1.x
    Issue #3350477 by mrshowerman, mark_fullmer, mmarler: Add test coverage...
mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mark_fullmer’s picture

Title: Add test coverage for rel and target settings » Linkit for Link Field: "rel" and "target" settings are removed for internal links
Version: 6.0.x-dev » 6.1.x-dev
Status: Closed (fixed) » Active

With #2885351: Query string duplications added in Drupal 10.2.3, this is now a problem as it was originally reported by mrshowerman. The previously added test coverage IS now failing on Drupal 10.2.3. The original proposed patch resolves the issue.

  • mark_fullmer committed 640b9b08 on 6.1.x
    Issue #3350477 by mark_fullmer, mrshowerman: Linkit for Link Field: "rel...
mark_fullmer’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.