In Drupal 10.2 versions, options are not set anymore on the link element in viewElements() of the LinkFormatter - see https://www.drupal.org/project/drupal/issues/2885351 and https://git.drupalcode.org/project/drupal/-/merge_requests/5333/diffs?co...

Also LinkitFormatter (I tested with linkit 6.1.3) overrides the url attributes option for linkit entity urls and these get lost (probably somewhere here $url = $this->getSubstitutedUrl($link_item)) which means they can't be set in the preRenderLink() method from the Link render element.

All of these combined contribute to the fact that link attributes are not set for linkit entity links.

Issue fork linkit-3441789

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

adinac created an issue. See original summary.

larowlan’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

Do you have any custom preprocessing?
Does this happen with a core theme?

larowlan’s picture

adinac’s picture

Category: Support request » Bug report
Status: Postponed (maintainer needs more info) » Active

I have seen that issue and no, we don't have any custom preprocessing for links.

larowlan’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

This module does not provide a formatter or do anything for output, it only provides a widget for editing.
Is the value there when you edit? If so the issue is in the theme or somewhere else

adinac’s picture

Project: Link Attributes widget » Linkit
Version: 2.1.0 » 6.1.x-dev
adinac’s picture

Since the attributes get lost in the LinkitFormatter viewElements() when the url is overwritten for entity links ($url = $this->getSubstitutedUrl($link_item)), I decided to move this issue to the linkit module.

adinac’s picture

Status: Postponed (maintainer needs more info) » Active
adinac’s picture

mark_fullmer’s picture

Status: Active » Needs work

Thanks for reporting this! Can you provide steps to reproduce? Ideally, we can use those to model new test coverage to ensure that attributes don't go missing again!

mark_fullmer’s picture

Status: Needs work » Needs review

I was aware of #2885351: Query string duplications and had commented on the implications for Linkit in https://www.drupal.org/project/drupal/issues/2885351#comment-15461298 . We' addressed the problem for the two attributes supported by the Linkit formatter with #3350477: Linkit for Link Field: "rel" and "target" settings are removed for internal links, but I follow your hypothesis that other atttributes could be lost during the call to $url = $this->getSubstitutedUrl($link_item).

Adding a merge request that replicates the logic from #9, which no longer applies to 6.1.x

  • mark_fullmer committed e54f7c5a on 6.1.x
    Issue #3441789 by mark_fullmer, adinac: Link attributes are not set for...
mark_fullmer’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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