-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript error if dropbutton library is loaded when there are no dropbuttons on the page #6257
Comments
@argiepiano thank you for filing the report, and @bugfolder thanks for the quick pull request! I've applied the PR to the site where I discovered the bug, and it fixes the issue for me. |
As a side note, The JavaScript variable names to use are described in JavaScript Coding Standards / Variables.
It is a rather written Backdrop convention. |
@kiamlaluno, would you be willing to do the code review on this PR? |
For what I can see, the code is correct. It also uses |
Changing the label to reflect the code review. A small sidenote: there is no |
By @bugfolder, @argiepiano, @olafgrabienski, and @kiamlaluno.
By @bugfolder, @argiepiano, @olafgrabienski, and @kiamlaluno.
Thanks @bugfolder, @argiepiano, @olafgrabienski, and @kiamlaluno! I have merged backdrop/backdrop#4538 into 1.x and 1.26.x. |
Description of the bug
This bug happens in combination with #6256. As reported there, the dropbutton JS library is loaded even when the Manage taxonomies Dashboard block is not actually rendered.
When the dropbutton library is loaded, and when there are no dropbuttons on the page, there is a JS failure in the newly introduced method
Backdrop.behaviors.dropButtonWidths
- see #6180.This was first reported in Zulip
Steps To Reproduce
To reproduce this, we'll force an error that happens because of the combination of this bug, and another reported in #6256.
To reproduce the behavior:
jQuery.Deferred exception: Cannot read properties of undefined (reading 'split') TypeError: Cannot read properties of undefined (reading 'split')
The admin bar stops working, since JS crashed
Actual behavior
JS crashes, admin bar stops working.
Expected behavior
Things should still work even if there are no dropbuttons in the page.
Additional information
Add any other information that could help, such as:
I believe the solution is simple: after doing this in that method
We should check to see if link actually has content.
By the way, following an unwritten Backdrop convention, the variable should be
$link
, notlink
, since this holds a jQuery object.The text was updated successfully, but these errors were encountered: