Closed (fixed)
Project:
Linkit
Version:
7.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
3 Feb 2026 at 11:06 UTC
Updated:
16 Mar 2026 at 14:25 UTC
Jump to comment: Most recent, Most recent file
The issue with JS error TypeError: Cannot read properties of undefined (reading 'attributes') being thrown seems to still persist in some cases even after the fixes in #3557993 and #3535098
This seems to happen only when:
Additionally editing the CKEditor field is no longer possible with further JS errors being thrown:
Uncaught CKEditorError: mapping-model-offset-not-found {"modelOffset":24,"viewContainer":{"path":[0],"type":"ContainerElement","root":"main","name":"p","children":[{"path":[0,0],"type":"Text","root":"main","data":"fqwfqwf qwf "},{"path":[0,1],"type":"AttributeElement","root":"main","name":"a","attributes":{"href":"/node/59849","data-entity-type":"node","data-entity-uuid":"65f94056-0a4c-4ec0-a639-dbb41edacadb","data-entity-substitution":"canonical"},"children":[{"path":[0,1,0],"type":"Text","root":"main","data":"qwf 12"}]},{"path":[0,2],"type":"Text","root":"main","data":" "},{"path":[0,3],"type":"AttributeElement","root":"main","name":"span","attributes":{"class":"ck-fake-link-selection"},"children":[{"path":[0,3,0],"type":"Text","root":"main","data":"qf"}]}]}}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-mapping-model-offset-not-found
at oo._findPositionStartingFrom (ckeditor5-dll.js?v=47.3.0:5:319845)
at oo.findPositionIn (ckeditor5-dll.js?v=47.3.0:5:319485)
at on.priority (ckeditor5-dll.js?v=47.3.0:5:315853)
at oo.fire (ckeditor5-dll.js?v=47.3.0:5:670015)
at oo.toViewPosition (ckeditor5-dll.js?v=47.3.0:5:318284)
at oo.toViewRange (ckeditor5-dll.js?v=47.3.0:5:318052)
at ckeditor5-dll.js?v=47.3.0:5:566273
at _e._callPostFixers (ckeditor5-dll.js?v=47.3.0:5:232937)
at Wt.change (ckeditor5-dll.js?v=47.3.0:5:295875)
at _e.<anonymous> (ckeditor5-dll.js?v=47.3.0:5:789759)Uncaught CKEditorError: cannot-change-view-tree
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-cannot-change-view-tree
at Wt.change (ckeditor5-dll.js?v=47.3.0:5:295597)
at Wt._disableRendering (ckeditor5-dll.js?v=47.3.0:5:296578)
at listenTo.priority (ckeditor5-dll.js?v=47.3.0:5:371357)
at gn.fire (ckeditor5-dll.js?v=47.3.0:5:670015)
at gn._runPendingChanges (ckeditor5-dll.js?v=47.3.0:5:495766)
at gn.change (ckeditor5-dll.js?v=47.3.0:5:493735)
at me._hideFakeVisualSelection (link.js?v=47.3.0:5:50905)
at me._removeFormView (link.js?v=47.3.0:5:47115)
at me._hideUI (link.js?v=47.3.0:5:47697)
at callback (link.js?v=47.3.0:5:44875)| Comment | File | Size | Author |
|---|---|---|---|
| #10 | ui- error.gif | 536.16 KB | angel_devoeted |
| #10 | linkit-build.jpg | 125.62 KB | angel_devoeted |
| #9 | linkit-text-full-paragraph.gif | 254.62 KB | mark_fullmer |
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
Comment #2
mark_fullmerLe sigh! Thanks for reporting this.
Comment #4
artis.bajars commentedTook a shot at debugging this. Two key changes to the plugin made it work for me:
linkit_attributesfrom the decorators object before passing to the link command.Did not spot any regressions or resurfacing of problems mentioned in the linked issues.
Note: The
editor_advanced_linkmodule uses an almost identical pattern and the JS errors return when it is enabled alongside Linkit. If this seems like a valid fix, the same kind of changes would need to be made there as well.Comment #5
artis.bajars commentedComment #6
artis.bajars commentedComment #7
mark_fullmerThanks for the proposed code changes! I'll prioritize reviewing the code and putting this through a fair amount of manual testing, since the permutations of how links can be entered and edited are numerous.
If this bears out, yes, we should refer the same approach to the editor_advanced_link module.
Comment #8
angel_devoeted commentedTested on branch 3571226-ckeditor-v45-displayed-text (MR !160).
I can still reproduce the same JS error (Cannot read properties of undefined (reading 'attributes')) following the steps in the issue (entire paragraph / last word + adding characters to “Displayed text”).
The compiled plugin (js/build/linkit.js) still derives displayedText as args[args.length - 1] || args[1].linkit_attributes.displayedText.
Comment #9
mark_fullmerIn my testing, the staged MR (!160) resolves the issue and I am not able to reproduce the problem after multiple variations, while I am easily able to reproduce the problem on the 7.x development branch.
Given the different result in #8 by @angel_devoeted, can you confirm, just to make 100%, by trying again -- and can you confirm you rebuilt the site cache after switching branches? If you are still able to reproduce, would you be able to link to a video screencast of the exact steps you took, since my result is different. Here is a video screencast of a successful test using this branch:
Comment #10
angel_devoeted commentedThanks for checking this again. I tested once more on the MR branch, rebuilt caches, and I can still reproduce the issue on my side (testing on Drupal Forge).
The served linkit.js does include the MR changes.
After inserting the link, the editor throws
TypeError: Cannot read properties of undefined (reading 'attributes'),
followed by mapping-model-offset-not-found, and the editor becomes unstable.
I’m testing on Drupal Forge, so this might be environment-specific, but I can reproduce it consistently here.
Let me know if you’d like me to try anything else.
Comment #11
artis.bajars commented@angel_devoeted what version of Drupal core are you testing with? In my case it's 11.3.3. CKEditor was updated to v47.3.0. in 11.3.0 so I'm wondering if that could affect something.
Comment #12
angel_devoeted commented@artis.bajars i’m testing on Drupal Forge with Drupal core 11.4-dev. CKEditor is loading as v47.3.0 here as well.
Comment #13
jannakha commentedThanks for the patch!
Drupal 10.6 on local working environment:
Before applying patch I was getting same errors as #10
After patch - no errors! link text and URL are updated as expected.
I can RTBC if anyone else can confirm
Comment #14
mark_fullmerI think before we can RTBC we need to understand why the error is still happening per comment #10.
Comment #15
artis.bajars commentedTried it out by spinning up a clean demo site on DrupalForge as well. Cannot replicate the bug there. Also, surely the version that was meant is
11.3.x-devright?Comment #16
angel_devoeted commentedTested again on Drupal Forge with core 11.4-dev (CKEditor 47.3.0), caches rebuilt, and I can still reproduce the error on my side.
That said, since others confirm the MR fixes the issue and it can’t be reproduced on a clean install, this is likely environment/config-specific in my setup, so I don’t think it should block RTBC.
I’ll try to isolate it locally and report back if I find a minimal reproducer.
Comment #17
mark_fullmerYeah, I'm inclined to proceed to merge this and cut a new release to fix the issue, apparently, for at least most setups. If the problem persists, people will report it and we may get more help on determining steps to reproduce.
Thanks, everyone!
Comment #20
jannakha commentedcheers!
Comment #21
scampbell1 commentedI am using CKEditor 4 on 10.6.3 and am getting this error
Uncaught Target element must have a data-drupal-selector attribute ending in "-uri". <input data-drupal-selector="edit-attributes-href" aria-describedby="edit-attributes-href--3guCtMRSaRw--description" class="form-linkit-autocomplete form-text form-element form-element--type-text form-element--api-linkit ui-autocomplete-input" data-autocomplete-path="/linkit/autocomplete/default" type="text" id="edit-attributes-href--3guCtMRSaRw" name="attributes[href]" value="" size="60" maxlength="2048" data-once="linkit-autocomplete" autocomplete="off">Comment #22
mark_fullmerThe latest major version iteration of Linkit (7.x) does not provide support/integration for CKEditor 4, unfortunately.
Comment #23
tlo405 commentedI'm actually seeing the same problem from #21 (Drupal 10.6.3 using the latest linkit 7.0.13), except I am on CKEditor5.
I have a custom form field that looks like this:
With the latest update, I now get an error when I attempt to select a link from the autocomplete dropdown. If I change the field name to be
button_uriinstead ofbutton_linkthen it works. Because now thedata-drupal-selectorattribute ends in "-uri". I don't know if this is the expected behavior though? Doesn't seem like I should have to change the name of my form fields to get this to work.Comment #24
mark_fullmerHrmm, thanks for reporting this, tlo405. Given that the trigger you're describing doesn't involve CKEditor5 (correct me if I'm wrong; the details indicate that you're using Linkit's link field element, not Linkit's CKEditor integration), this feels like it doesn't have anything to do with the change from this issue or from the latest release of Linkit (7.0.13). Would you be able to open a separate issue for what you're experiencing?