Problem/Motivation

When a link style is applied using the "Styles" dropdown, it can generate multiple links in the markup rather than a single link.

Note: Drupal uses the CKEditor "Styles" dropdown plugin more or less as-is. The problem can be produced in the context of a Drupal build but is not reproducible on a generic build of CKEditor, as shown in this video: https://www.drupal.org/files/issues/2025-10-09/ckeditor-default.mov

Steps to reproduce

Screencast of problem:

1. Install Drupal core (11.2.x) using the "Standard" installation profile
2. Go to admin/config/content/formats and choose the "Basic HTML" text format
3. Add the "Style" dropdown to the CKEditor 5 toolbar
4. Under the CKEditor plugin settings for "Style" add a.btn|Button
5. Create a Basic page and add a link using the Link toolbar (text: "text", link: "https://drupal.org"), and insert the link into the content.
6. Use the "Styles" dropdown to apply the "Button" class to the existing link.
7. Important step!: Click somewhere within the text of the link (do not highlight the link; this is so that the CKEditor selection is "collapsed," which is a necessary precondition for the problem).
8. Click the "Link" icon in the toolbar.
9. Use the link "Pencil" icon to change the displayed text of the link.
10. Press the "Update" button in the link balloon.
11. Inspect the page source. There are now two links, divided by the text, when there should be one.

Potential root cause

Drupal 10.5/11.2 updated to CKEditor version 45 per #3523018: Update CKEditor 5 to 45.2.0. This version of CKEditor introduces API changes to the Link widget, including, notably, a new "Displayed text" input field for updating the text associated with the link. Due to this change, the way that implementers calculate the range of the selection to be updated may need to account for changes to the "Displayed Text." This same problem was observed in contributed modules Linkit and Editor Advanced Link, and the resolution was to change the range calculation: #3540235: [CKEditor v45] Editing Displayed text from collapsed selection generates multiple links and #3534699: [CKEditor5 v45+] Attributes can overwrite other attributes and editing displayed text from collapsed selection generates multiple links . However, there seems to be no equivalent code in Drupal.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

mark_fullmer created an issue. See original summary.

mark_fullmer’s picture

Issue summary: View changes
StatusFileSize
new1.14 MB
quietone’s picture

Version: 11.2.x-dev » 11.x-dev

Just updating the version number as changes are fixed on 11.x first.

gold’s picture

Can confirm I am getting the same behaviour on 10.5.6 (standard core set up with no third party modules installed).

I've also been getting this behaviour with any attributes on a link tag, not just the styles dropdown adding a class. Eg title, id, aria-label.

Is this a CKEditor issue? Or a CKEditor in Drupal issue?

ericgsmith’s picture

Confirm this is happening on client sites with Drupal 10.5.x and 11.2.x - I can not reproduce this in 11.x / 11.3.x though - I suspect something in CKEditor was fixed (11.2 is v45.2.0, 11.3 is v47.1.0)

Couldn't see anything specific related to this in the changelog though - maybe somehow impacted by https://github.com/ckeditor/ckeditor5/issues/19193 / https://github.com/ckeditor/ckeditor5/pull/19192 (issue currently says open but is in changelog for 47.1.0)

Testing on 11.x:

ericgsmith’s picture

StatusFileSize
new1.44 MB
mark_fullmer’s picture

I can corroborate the observation in #5, namely: I can reproduce this on Drupal core 11.2.x, but not on 11.3.x.

ishani patel’s picture

Hello,
I can not reproduce this issue with this version D11.2.2

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

jastraat’s picture

Looks like this may have been resolved in ckeditor5 47.3.0