Cannot replace 'Displayed text' of existing links

Created on 10 July 2025, 2 days ago

Problem/motivation

During our testing for the upgrade to Drupal 10.5.x, we identified a bug that occurs when attempting to update the "Displayed text" of an existing link.

Drupal 10.5.1
Linkit 7.0.6
Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes')
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-Cannot read properties of undefined (reading 'attributes')
    at mi.getChanges (ckeditor5-dll.js?v=45.2.0:5:428639)
    at html-support.js?v=45.2.0:5:29843
    at vi._callPostFixers (ckeditor5-dll.js?v=45.2.0:5:442557)
    at vi._handleChangeBlock (ckeditor5-dll.js?v=45.2.0:5:441779)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476270)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)
    at _.<anonymous> (editorAdvancedLink.js?v=10.5.1:1:2664)
    at _.fire (ckeditor5-dll.js?v=45.2.0:5:639290)
    at <computed> [as execute] (ckeditor5-dll.js?v=45.2.0:5:642831)
    at f.execute (ckeditor5-dll.js?v=45.2.0:5:163419)
ckeditor5-dll.js?v=45.2.0:5 Uncaught CKEditorError: document-selection-wrong-position {"range":{"start":{"root":"main","path":[0,9],"stickiness":"toNone"},"end":{"root":"main","path":[0,9],"stickiness":"toNone"}}}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-document-selection-wrong-position
    at Co._validateSelectionRanges (ckeditor5-dll.js?v=45.2.0:5:329930)
    at Co._replaceAllRanges (ckeditor5-dll.js?v=45.2.0:5:329670)
    at Co._setRanges (ckeditor5-dll.js?v=45.2.0:5:320078)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:319218)
    at Co.setTo (ckeditor5-dll.js?v=45.2.0:5:328804)
    at Ao._setTo (ckeditor5-dll.js?v=45.2.0:5:326266)
    at Pi.setSelection (ckeditor5-dll.js?v=45.2.0:5:455870)
    at Object.callback (ckeditor5-dll.js?v=45.2.0:5:356853)
    at qi._runPendingChanges (ckeditor5-dll.js?v=45.2.0:5:476216)
    at qi.change (ckeditor5-dll.js?v=45.2.0:5:473265)

Steps to reproduce

While I havenโ€™t been able to reproduce the issue consistently, I can trigger the error approximately 90% of the time. Given this frequency, I believe it's worth creating an issue for further discussion and investigation.

  1. Edit an existing link
  2. Try to update the 'Displayed text'

P.S. It seems that appending text doesnโ€™t trigger the error, but replacing the entire text does make it more likely to occur.

๐Ÿ› Bug report
Status

Active

Version

7.0

Component

Code

Created by

๐Ÿ‡น๐Ÿ‡ผTaiwan peterwcm

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

Merge Requests

Comments & Activities

  • Issue created by @peterwcm
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson

    Thanks for reporting this. I am able to reproduce. Specifically, using a generic installation of the Standard profile, adding Linkit to the Basic HTML text format:

    1. Click the "Link" icon.
    2. Enter a "Displayed text" value.
    3. Enter the first character of an existing node and use Linkit's autocomplete to choose a result from the dropdown. Confirm that the internal path to the node is populated in the "Link URL" field.
    4. Quickly(!) Remove the contents from the "Displayed text" input and quickly enter new text and press "Insert."
    5. Link text will not be updated and the console will show the Uncaught CKEditorError: Cannot read properties of undefined (reading 'attributes') error.

    Additionally, this is something else that doesn't work correctly.
    1. Click the "Link" icon.
    2. Enter a "Displayed text" value.
    3. Enter the first character of an existing node and use Linkit's autocomplete to choose a result from the dropdown. Confirm that the internal path to the node is populated in the "Link URL" field.
    4. Now click "Link URL" field again and enter the first character of another node and use Linkit's autocomplete to choose a different result.
    5. The link field will NOT correctly populate the internal path to the node but will simply populate the character you entered.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States mark_fullmer Tucson

    I've merged a number of changes related to CKEditor v45 compatibility to reduce the surface area here. The originally reported problem still remains, so this is "Needs work."

Production build 0.71.5 2024