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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Entity-browser-modals-not-close-on-content-types-where-Mercury-is-not-enabled-3492298.patch | 2.74 KB | niharika.s |
Issue fork mercury_editor-3492298
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 #2
niharika.s commentedComment #3
niharika.s commentedI have resolved the issue by applying all the necessary changes. Please review the changes and let me know if any further adjustments are required.
Comment #4
sethhill commentedComment #5
jrockowitz commentedI 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'.
Comment #6
jrockowitz commentedMarking 'Major' since this is a significant problem when JS aggregation is enabled.
Comment #14
sethhill commentedWe 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.