Adding "Open in new window" removes all other attributes

Created on 3 July 2025, 29 days ago

Problem/Motivation

Enabling "Open in new window" removes all existing attributes from the link.

Workaround for this issue is to first enable "Open in new window" and then add other attributes.

Steps to reproduce

  1. Create link and set any of the attributes: title, class, id, relationship, aria label.
  2. Save and confirm that all the attributes are properly added to the link.
  3. Edit the link again
  4. Click on "Link properties" and enable "Open in new window" option
  5. Save
  6. Verify that "target" attribute has been added but all the attributes set in step 1 are now gone.

Proposed resolution

Adding the "target" attribute should preserve other attributes.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

2.3

Component

Code

Created by

🇷🇸Serbia vaish

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

Comments & Activities

  • Issue created by @vaish
  • 🇮🇳India ankush_03 Gurgaon, India 🇮🇳
  • 🇦🇺Australia jannakha Brisbane!

    CKEditor5 45+ had some major changes on how they are processing attributes,
    can you test this patch: https://www.drupal.org/project/editor_advanced_link/issues/3534699 📌 Refactor custom JS for CKEditor5 v45+ Active

  • 🇷🇸Serbia vaish

    Thanks, @jannakha. MR !37 does fix this issue. As far as I can see, it also fixes the issue 🐛 Fix keyboard accessibility of advanced attribute fields Active .

  • 🇦🇺Australia marc.groth

    Hey @vaish could you please confirm what setup you have? I applied the patch referenced in #4 and it doesn't work for me. The link works fine until I select the 'Open in new window' functionality... Where the previous attributes are then lost. For one thing this results in the node ID itself being output in the source code as opposed to the alias (because of the missing data-entity-uuid attribute).

    That ticket ( https://www.drupal.org/project/editor_advanced_link/issues/3534699 📌 Refactor custom JS for CKEditor5 v45+ Active ) even says that this particular issue is still a remaining task... So I'm wondering how you got this working?

    In case it is useful, my setup is follows:

    Drupal core 10.5.1
    Editor Advanced link 2.3.1
    Linkit 7.0.7

  • 🇷🇸Serbia vaish

    Hey @marc.groth, I believe I know where is the confusion coming from. I usually add "open in new window" to external links so in my tests I always used external links and was focused on attributes added by Editor Advanced Link. If you check again, you will see that those attributes are indeed preserved after applying the patch from MR37. However, attributes that you are talking about are data-* attributes generated by Linkit module. Just now I verified that those get lost even with this patch applied.

    My setup:
    Drupal core 10.5.1
    Editor Advanced link 2.3.1 with patch from MR 37 dated 9 Jul 2025
    Linkit 7.0.5

  • 🇦🇺Australia marc.groth

    Thanks @vaish. That actually makes a lot of sense. You're right, the 'target' attribute is kept... But the other data attributes are removed.

    @jannakha should that be fixed in this ticket? Presumably after ticket #3534699 is finalised otherwise it will likely result in conflicts?

  • 🇨🇦Canada endless_wander

    I cannot apply MR37 from 3534699.

    D10.5.1 and Editor Advanced Link 2.3.1.

    I have same reported problem when using LinkIt 7.0.5 where any data- attributes are removed if any functionality from Editor Advanced Link module is used.

    For example, a LinkIt-formatted link like this:

    <a href="/node/25" data-entity-type="node" data-entity-uuid="919a970f-095b-4caa-aab7-40385d426bf5" data-entity-substitution="canonical" aria-label="my label">test</a>

    Becomes this after using "Open in a new window" with Editor Advanced Link:

    <a href="/node/25" target="_blank">test</a>

  • 🇦🇺Australia jannakha Brisbane!

    for comment #9 - it's not this modules' issue
    see linkit: https://www.drupal.org/project/linkit/issues/3535479 📌 Refactor Linkit plugin for CKEditor5 v45+ Active

    CKEditor5 v45+ removes all attributes by default, unless Drupal's module's tries to persist them.
    unfortunately CKEditor5 team doesn't want to implement any of the link attributes like title, id, class, etc - so we are stuck with our own implementation.

    I would actually change status of this issue to "closed (won't fix)" - but we'll keep the discussion for now.

    For example, if you uninstall editor_advanced_link and use CKEditor's own module which adds open in new tab ( https://www.drupal.org/project/ckeditor5_plugin_pack ) you'll have the same issue.

    all other modules have to fix persistence of their own attributes.

Production build 0.71.5 2024