Problem/Motivation

When using the Editor Advanced Link module together with other CKEditor 5
plugins, the editor
can throw a JavaScript error and break the editing experience.

The error occurs because EditorAdvancedLinkUI assumes that LinkUI.formView
is always initialized when the ContextualBalloon plugin changes its
visible view. In some editor states, this assumption is not true and
formView is still null.

This results in a runtime error such as:

"Cannot read properties of null (reading 'linkTitle')"

Once the error occurs, CKEditor 5 becomes unstable and users may be unable
to continue editing content.

Steps to reproduce

  1. Start from a clean Drupal installation.
  2. Enable CKEditor 5 and the Editor Advanced Link module.
  3. Configure a text format using CKEditor 5 and enable advanced link attributes (e.g. title, aria-label, class).
  4. Enable an additional CKEditor 5 plugin that opens or closes UI elements using ContextualBalloon (for example, a custom table or accessibility plugin).
  5. In the editor, insert or edit content in a way that causes the ContextualBalloon visible view to change.
  6. Open the link dialog.

Result:

A JavaScript error is thrown because LinkUI.formView is null.

"Cannot read properties of null (reading 'linkTitle')"

See attached screenshot showing the JavaScript error thrown in the browser console.

Expected result:

The link dialog opens without errors and the editor continues to work
normally.

Proposed resolution

Add defensive checks in EditorAdvancedLinkUI to ensure that LinkUI.formView
exists before attempting to access or extend it.

Patch that:

  • Verifies that LinkUI.formView is initialized before comparing it with the visible view.
  • Safely aborts component registration when the link form is not available.
  • Prevents runtime JavaScript errors caused by null formView access.

The fix should follow the CKEditor 5 UI plugin best practices and not alter existing behavior when the form view is available.

Remaining tasks

  • Create the patch.
  • Confirm that the fix works across supported Drupal and CKEditor 5 versions

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon 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

teresa_rodriguez created an issue. See original summary.

teresa_rodriguez’s picture

Issue tags: -JavaScript +JavaScript
teresa_rodriguez’s picture

I am attaching a patch that fixes the JavaScript error caused by accessing
LinkUI.formView when it is still null.

The patch adds defensive checks in EditorAdvancedLinkUI to ensure that the
link form view exists before comparing or extending it. This prevents the
runtime error:

Cannot read properties of null (reading 'linkTitle')

The fix has been tested locally with CKEditor 5 and additional plugins that
use ContextualBalloon, and resolves the issue without affecting normal link
dialog behavior.

Note: This patch updates both the source file:
js/ckeditor5_plugins/editorAdvancedLink/src/editoradvancedlinkui.js
and the compiled asset:
js/build/editorAdvancedLink.js

Including the built file is intentional, as this module ships versioned
CKEditor 5 assets and Drupal.org does not run frontend build steps.
This is consistent with common practice in CKEditor 5 modules for Drupal.

teresa_rodriguez’s picture

Status: Active » Needs review
Issue tags: +ckeditor5
jannakha’s picture

Version: 2.3.3 » 2.3.x-dev

@teresa_rodriguez thank you for reporting the issue in detail and creating a patch.
Please create a merge request in the future - it will speed up reviewing/testing process.

I'm in the process of reviewing the patch.

vladimiraus’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies and working.
RTBC.

  • JannaAus committed c26b2653 on 2.3.x
    Issue #3563735 : Fix JS error when LinkUI.formView is null (CKEditor 5)
    
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thanks you for your contributions.
Merged. 🍻

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.