Problem/Motivation

I'm currently getting this JS error on a regular basis:

Uncaught TypeError: can't access property "prototype", Drupal.AjaxCommands is undefined
https://standard-vscode-drupal.ddev.site/modules/contrib/canvas_builder/...

Once the error occurs, changes are no longer saved.

However, when I log Drupal.AjaxCommands in the console manually, it's there. So it might be some kind of a “timing problem.”

Another error appears when typing in an SDC text field:

Uncaught TypeError: d[_] is not a function
T https://standard-vscode-drupal.ddev.site/modules/contrib/canvas/ui/dist/...

Tested with:
- Drupal: 11.4.4
- Canvas: 1.8.0
- Theme: Olivero

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

thomas.frobieter created an issue. See original summary.

  • aaronchristian committed 7459dbf4 on 1.0.x
    fix(canvas_builder): repair two alpha2 bugs, Tailwind purge, and...
aaronchristian’s picture

Assigned: Unassigned » aaronchristian
aaronchristian’s picture

Thanks for reporting @thomas.frobieter.

It turned out to be a load-order issue in our JS rather than Canvas core. Canvas Builder was patching Drupal.Ajax/Drupal.AjaxCommands too early, and depending on cache state, JS aggregation, and timing, those APIs weren't always available yet. When that happened, the rest of the file never ran, including the bit that adds the active viewport to AJAX requests, which is why edits stopped saving.

The fix now waits until Drupal.Ajax and Drupal.AjaxCommands actually exist before applying the patches, so it's no longer dependent on load order.

I tested it with JS aggregation on and off, forced the failure scenario, and ran through sections, columns, and SDC text fields. Everything saved correctly with no more Drupal.AjaxCommands is undefined or d[_] is not a function errors.

It's on 1.0.x now (commit 7459dbf) if you want to give it a spin.

aaronchristian’s picture

Status: Active » Needs review

  • aaronchristian committed 98254939 on 1.0.x
    chore(canvas_builder): pre-alpha3 audit — dead code, doc drift, and two...
anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the important fixes @aaronchristian! Great work!

grevil’s picture

Status: Reviewed & tested by the community » Fixed

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.

grevil’s picture

Assigned: aaronchristian » Unassigned
aaronchristian’s picture

Status: Fixed » Closed (fixed)