Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
This image captures the bug. It shows a Drupal 8 site on the /admin path. The debugger is paused on line 53 contextual.toolbar.js. In this case, we are trying to access Drupal.contextual.collection, but Drupal.contextual is not defined.
Comment | File | Size | Author |
---|---|---|---|
#11 | core-js-contextual-backbone-1971108-11.patch | 2.5 KB | nod_ |
#3 | core-js-contextual-error-admin-1988328-3.patch | 1.92 KB | nod_ |
#1 | contextual-collections-bug-1988328-1.patch | 2.41 KB | jessebeach |
Screenshot_5_6_13_1_39_PM.png | 265.62 KB | jessebeach |
Comments
Comment #1
jessebeach CreditAttribution: jessebeach commentedHere's the patch that fixes it. We need to check for Drupal.contextual before accessing Drupal.contextual.collection.
Comment #2
Wim LeersThere already is a follow-up patch on the issue that introduced this: #1971108-36: Convert contextual.js to use Backbone (and support dynamic contextual links). It solves it very differently though. This is slightly more complex, but also better for front-end perf.
Let's figure out the best solution here.
Comment #3
nod_I'm more for something like #1 than adding the dep to the script.
Comment #4
nod_Same fix as in #1 with a nicer syntax.
Comment #5
nod_If it wasn't for #1639012: Guard against broken behaviors it'd be a critical bug :p
Comment #6
Wim Leers:)
Comment #7
tim.plunkettI only found it because I run hacked core JS to expose stuff like this.
Comment #8
alexpottNeeds reroll...
Comment #9
nod_turns out #914382: Contextual links incompatible with render cache fixed it so it's all good.
Comment #10
Wim Leers#9: actually, the solution applied in #914382: Contextual links incompatible with render cache is suboptimal, as you already said in #3. So this patch should still be rerolled, and should remove the dep introduced by #914382: Contextual links incompatible with render cache.
Comment #11
nod_Umm, sure, but in contextual_page_build there is
$page['#attached']['library'][] = array('contextual', 'drupal.contextual-links');
Which means that it'll be on the page regardless.
Anyway, here is the patch. Made into an anonymous function otherwise a js checking tool complains about a function defined in a if (because of hoisting and that sort of things).
Comment #12
Wim LeersYou're right. But it's possible that somebody removes the library in
hook_page_alter()
for some reason, and then thanks to #11 we still won't break. So it's still better :)Thanks!
Comment #13
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks!
Comment #14
Wim Leers.