Problem/motivation
When editing an existing link in CKEditor 5, toggling a manual decorator such as Open in new window immediately closes the link balloon. The decorator change is applied correctly to the model/HTML, but the balloon disappears on click, so the user gets no visual feedback and cannot continue editing without reopening the link.
This doesn't happen with new links.
You need to enable the : Editor Advanced link module and on the text_format enable the 'target' option + on the text_format enable Linkit with the Default profile.
Steps to reproduce
- With Linkit 7.0.x enabled on a text format with the Linkit profile 'Default' selected
- Add and enable the Editor Advanced link 2.3.x module and on the text format enable the option Advanced links =>'Open in new window ()'
- Ppen any node edit form with a CKEditor field.
- Type some text, select it, and create a link.
- Dismiss the balloon (e.g. click elsewhere in the text) so the link is committed.
- Click the link again to reopen the balloon.
- Toggle the Open in new window switch.
- Observe: the balloon closes immediately on click. Expected: the balloon stays open and the decorator is toggled/applied (which it is, but invisibly).
What happens
- You toggle “Open in New Window” on an existing link.
- Linkit then moves the cursor to the end of the link (setSelection(range.end)).
- The balloon is pinned to the link; this cursor movement causes it to “come loose” → the balloon closes.
- That cursor movement is only supposed to happen when you change the link text (to prevent caret issues), not when toggling a decorator—but it always happened.
Proposed resolution
Move the cursor only when text has actually been changed, not when toggling a decorator (in which case it is an object). → The balloon remains open.
Issue fork linkit-3612706
Show commands
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 #3
anneke_vde commentedComment #4
anneke_vde commentedComment #5
anneke_vde commentedThe fix in the mr moves the caret only when the displayed text actually changed (i.e. displayedText is a string). When a decorator is toggled, displayedText is the decorator/options object, so setSelection is skipped and the balloon stays open. The caret-gravity handling for text replacement is left untouched.
Why the fix is scoped to decorator toggles and not to link text/URL edits:
The setSelection(range.end) call exists on purpose: when a link's displayed text is replaced, the caret has to be moved to the end of the link and its gravity corrected, otherwise attributes (e.g. bold, or Linkit's own data-entity attributes) stick to the caret and leak into text typed afterwards.
Comment #6
anneke_vde commentedComment #7
anneke_vde commentedComment #8
idebr commentedThe link balloon now stays open when toggling the editor_advanced_link 'Open in new window' when editing a node.
The change was tested manually: test coverage for this issue would explicitly require another module to enable the Link attributes in the Link widget. I'm assuming this is out of scope.
Comment #10
mark_fullmerThanks for the issue report, the proposed fix, and the manual testing. I agree that it's not worth adding test coverage for this, given the amount of setup that would involve.