Doesn't work when aggregating javascript files

Created on 27 September 2024, 3 months ago

Problem/Motivation

I can edit and save a page when I have this in my settings file:
$config['system.performance']['js']['preprocess'] = FALSE;
BUT i cannot save when I have this in my settings file:
$config['system.performance']['js']['preprocess'] = TRUE;

That returns an ajax error:
An error occurred while attempting to process /layout-builder-ipe/entity/edit/overrides/node.3?ajax_form=1&entity_type=node&entity=3&_wrapper_format=drupal_ajax: ajax.$form.ajaxSubmit is not a function

I have added a video that demonstrates this problem.
Not that I made a few alterations (via a custom module) why the layout_builder_ipe looks a bit different in the video than 'out of the box':
- Changed the 'Customize' text to 'Edit page content' (via hook_layout_builder_ipe_links_alter)
- Moved it into the navigation_top_bar (via custom js)
- Styled it via css to have an icon and look like a button

Steps to reproduce

- enable and use layout_builder_ipe on a content type
- aggregate JS files (via /admin/config/development/performance or via $config['system.performance']['js']['preprocess'] = TRUE;)
- edit a node via layout_builder_ipe and try to save or cancel

Proposed resolution

I guess we first need to know if thats only a problem in my project, or that is indeed a general problem for everyone that uses layout_builder_ipe. I am not sure how to go about finding the exact cause or to fix it so that the module works when aggregating js files

Remaining tasks

- find cause
- fix it

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium flyke

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @flyke
  • 🇩🇪Germany berliner

    Thanks for reporting. Can you update this issue with the following information?

    1. Exact version of Drupal Core
    2. Exact version of this module (ideally git commit)
    3. Do you have any core patches applied?
  • 🇩🇪Germany berliner

    Just in case you are on Drupal 10.3, did you try the patch from 🐛 Logic error in Drupal's lazy load for asset aggregation Active ? It should also apply to Drupal 10, even though the issue is marked for 11.

  • 🇧🇪Belgium flyke

    My project uses:
    - drupal/core 10.3.5
    - drupal/layout_builder_ipe 1.0.0-beta9
    This combination has the ajax error.

    For testing I updated layout_builder_ipe to dev version:
    - drupal/core 10.3.5
    - drupal/layout_builder_ipe 1.0.x-dev@dev
    This combination also has the ajax error.

    Now I added patch from #3467860:

            "patches": {
                "drupal/core": {
                    "#3467860": "https://git.drupalcode.org/project/drupal/-/merge_requests/9219.diff"
                },

    This did fix the problem ! The ajax error is gone and I can save the page again with this config: $config['system.performance']['js']['preprocess'] = TRUE;

    Thank you for providing a solution !

  • 🇩🇪Germany berliner

    Great! I'll close this issue then and add a link to the core patch to the project page. Not sure how to prevent this issue otherwise.

Production build 0.71.5 2024