[CKEditor v45+] Using the Styles dropdown for a link results in multiple links in markup

Created on 9 October 2025, 24 days ago

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: https://www.drupal.org/files/issues/2025-10-09/drupal-core-link-collapse... β†’

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 πŸ“Œ Update CKEditor 5 to 45.0.0 Active . 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: πŸ› Editing Displayed text generates multiple links Active and πŸ“Œ Refactor custom JS for CKEditor5 v45+ Active . 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

πŸ› Bug report
Status

Active

Version

11.2 πŸ”₯

Component

ckeditor5.module

Created by

πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

Live updates comments and jobs are added and updated live.
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.

No activities found.

Production build 0.71.5 2024