- Issue created by @camoa
When the Viewer 3D module is enabled, Drupal core JavaScript functionality breaks across the site. This affects elements like the admin toolbar menu and other JavaScript-driven UI elements. No JavaScript errors are visible in the console, but JavaScript functionality simply stops working, rendering the admin interface difficult to use.
This issue was discovered after applying the patch from issue #3518609 π Fix Composer integration for Babylon.js libraries Active .
After investigation, two primary issues were identified that need to be fixed:
Issue 1: Global Library Attachment
The module attaches the Babylon.js library to every page through hook_page_attachments()
, regardless of whether the 3D viewer is present on the page. This causes unnecessary JavaScript loading and potential conflicts with core JavaScript.
Fix: Modify the module to only load its libraries on pages where the 3D viewer is actually used, likely by using a more specific hook or conditions.
Issue 2: Incorrect Event Listener Implementation
In viewer_3d_color.js, there's an immediate execution issue with the DOMContentLoaded event handler:
document.addEventListener("DOMContentLoaded", canvasRender());
This is calling the function immediately rather than setting it as a callback.
Fix: Correct the event listener implementation to properly defer execution until DOM is ready:
document.addEventListener("DOMContentLoaded", canvasRender);
None
None
None
Active
1.0
Code