- 🇬🇧United Kingdom catch
This looks like an issue introduced by custom code that we could make toolbar more resilient to, which isn't a critical bug.
It might be a duplication of https://www.drupal.org/project/drupal/issues/3305152 🐛 Toggle icon for toolbar menu missing for all tabs except Manage Needs work
- First commit to issue fork.
- Merge request !7933Issue 3310075 by redamakhchan, yookoala: Fix Toolbar js when no administation menu → (Open) created by yookoala
- 🇭🇰Hong Kong yookoala
yookoala → changed the visibility of the branch 3310075-toolbar-js-errors to hidden.
- Merge request !7934Issue 3310075 by redamakhchan, yookoala: Fix Toolbar js when no administation menu → (Open) created by yookoala
- Status changed to Needs review
about 1 year ago 8:26am 7 May 2024 - 🇭🇰Hong Kong yookoala
The fix has implemented to both 10.4.x and 11.x branch. Please review.
- Status changed to Needs work
about 1 year ago 10:53pm 8 May 2024 - 🇺🇸United States smustgrave
Issue summary mentions 2 solutions but no indication for which solution was chosen.
Not sure about the use case but if it seems like something people do will need test coverage I believe.
- 🇮🇳India arunkumark Coimbatore
Verified the MR !7934 has fixed the Issue. Not changing the issue status until the approach is decided as per #13.
Before
After
- 🇭🇰Hong Kong yookoala
I'd argue approach #1 and #2 are not mutually exclusive. While approach #2 is more of a user experience concern, approach #1 makes the code more resilient and robust either way.
- 🇺🇸United States pyrello
I think that approach #1 is appropriate to fix a JS error. Approach #2 seems like more of a feature request, even if it was previously a feature. Let's not let the possibility of a more robust feature block a simple JS fix for now.
@smustgrave Is it really necessary to add a test based on the addition of an if statement to check if a JS variable is set?
- 🇬🇧United Kingdom tce
I've run into this issue on a site where a restricted role uses the front-end theme. The toolbar loads, but .toolbar-loading is never removed, and the toolbar appears broken.
After debugging, I confirmed the crash happens in ToolbarVisualView.js when the orientation toggle button is missing:
$orientationToggleButton[0].value
Adding a simple guard resolves the issue cleanly:
// If the toggle button isn't present, exit early to avoid JS crash. if (!$orientationToggleButton.length) { return; }
This allows the rest of the toolbar JS to run, removes .toolbar-loading, and restores full toolbar visibility for the restricted role.