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
Comments
Comment #3
aaronchristian commentedComment #4
aaronchristian commentedThanks 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.AjaxCommandstoo 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.AjaxandDrupal.AjaxCommandsactually 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 undefinedord[_] is not a functionerrors.It's on
1.0.xnow (commit7459dbf) if you want to give it a spin.Comment #5
aaronchristian commentedComment #7
anybodyThanks for the important fixes @aaronchristian! Great work!
Comment #8
grevil commentedComment #10
grevil commentedComment #11
aaronchristian commented