Problem/Motivation

For content types that have a reference field using entity browser, but for which Mercury Editor is not enabled, a JavaScript error prevents the entity browser modal from closing. The issue can be traced to entity_browser.modal_selection.js, which throws this error message:

Uncaught TypeError: Cannot read properties of null (reading 'close')

A quick fix is to change the line
element.closest('mercury-dialog').close();
to
element.closest('mercury-dialog')?.close();

However, the larger concern appears to be that Mercury Editor libraries are loaded for any content type, regardless of whether or not Mercury is actually enabled for that content type.

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

sethhill created an issue. See original summary.

niharika.s’s picture

Assigned: Unassigned » niharika.s
niharika.s’s picture

Assigned: niharika.s » Unassigned
Status: Active » Needs review
StatusFileSize
new2.74 KB

I have resolved the issue by applying all the necessary changes. Please review the changes and let me know if any further adjustments are required.

sethhill’s picture

Status: Needs review » Active
jrockowitz’s picture

I am able to reproduce this issue which is coming from mercury_editor_library_info_alter() which adds 'mercury_editor/dialog.drupal' as a dependency to 'drupal.dialog'.

jrockowitz’s picture

Priority: Normal » Major

Marking 'Major' since this is a significant problem when JS aggregation is enabled.

sethhill changed the visibility of the branch 3493649-drop-d9-and to hidden.

  • sethhill committed 7e2ce7bc on 2.2.x
    Issue #3492298: Entity browser modals won't close on content types where...
sethhill’s picture

Status: Active » Fixed

We decided to go with the quick fix at the moment, as the work to change how Mercury Editor libraries are attached will require more changes than we want to make. Created #3493947: Mercury Editor libraries are attached to entity edit forms even when Mercury is not enabled for them to capture that need for future development.

Status: Fixed » Closed (fixed)

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