Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After the Shortcut module is disabled, the toolbar is still expanded. Javascript is used to correct this, but visiting a page with JS turned off reveals that the space for the Shortcut bar is still expanded (see attached D7 screen shot).
Comment | File | Size | Author |
---|---|---|---|
#18 | Screen Shot 2014-06-29 at 1.29.58 AM.png | 340.71 KB | mgifford |
#18 | Screen Shot 2014-06-29 at 1.29.19 AM.png | 386.04 KB | mgifford |
#17 | drupal-1215304-7.x.patch | 4.67 KB | danillonunes |
#14 | 0001-Issue-1215304-Toolbar-is-not-collapsed-after-Shortcu.patch | 4.03 KB | danillonunes |
#10 | 1215304-10.patch | 3.45 KB | Jody Lynn |
Comments
Comment #1
dboulet CreditAttribution: dboulet commentedPatch collapses toolbar when Shortcut module is disabled, restores it when it is enabled. Please review.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedReproduced the bug.
However, I think this a Toolbar module bug and any fix for it should be there, not in the Shortcut module.
Also, by doing it in hook_enable() and hook_disable(), doesn't that mean the bug is only fixed for the administrator who actually enables/disables the module, not any other users?
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedSo I think that the ideal way to fix this would be to modify this code:
The part where 'toolbar-drawer' is added to the page class shouldn't just check _toolbar_is_collapsed(), but also if the toolbar drawer has any content in it.
The problem is that there seems to almost be a conspiracy in the page rendering system to make that difficult or impossible to do. The 'page_top' region (in which the toolbar lives) is rendered in template_process_html(), so toolbar_preprocess_html() is too early to figure out if something was added to the drawer. And there doesn't seem to be a clean way to check later in the process.
Comment #4
dboulet CreditAttribution: dboulet commentedD'oh!
Thanks for the review David, I'll try to come up with a better solution.
Comment #5
theborg CreditAttribution: theborg commentedWhat about using js to remove toggle button in case drawer has no children? This patch also adapts padding.
Comment #6
Jody LynnThe previous patches were no good- This is not a js problem nor something only related to shortcut.
Because the toolbar drawer is intended to be used by other modules, not just shortcut, and there is no way to tell if the drawer will have content when creating the toolbar, I added a hook to determine if the toolbar has a drawer (and an implementation of it in shortcut).
This is needed both when adding the toolbar-drawer class to body (which caused the extra padding shown in the image in the initial issue) and when adding the toolbar toggle icon into the render array.
Comment #7
tim.plunkettShould be
@return bool
No need for this if statement, just foreach over it.
Also the new hook needs docs in toolbar.api.php
Comment #8
Jody LynnMade tim's changes.
Comment #9
tim.plunkettMissing the api docs, guessing you used `git diff` to roll the patch. In this case you'd have to git add everything first, and then git diff --staged.
Comment #10
Jody LynnAlright smartyhawk. Here it is, thanks
Comment #11
Jody LynnComment #12
tim.plunkettLooks good to me.
Tentatively tagging for backport? Unsure if that's possible.
Note that the entire bottom half of the patch is mostly indenting.
git diff -w
shows this:Comment #13
catchI'm not really comfortable with the new hook here, but don't really have a better idea given the inability to detect whether there's content or not in the toolbar without it. I think this could use more review to be honest.
Comment #14
danillonunes CreditAttribution: danillonunes commentedI don't think we are going in the right way. This bug is way more simple: There's a cookie that check if the toolbar is collapsed. We assume that the lack of the cookie means that the toolbar is expanded. But it's impossible to tell if it's really expanded, or just if there's nothing to be expanded (and therefore set the collapsed cookie).
I'm trying to fix it changing the cookie from Drupal.toolbar.collapsed to Drupal.toolbar.expanded.
That way, we always know when the toolbar is really expanded and when it's really collapsed, no matter if it's because the user collapse it or because there's no content to be expanded.
Comment #15
danillonunes CreditAttribution: danillonunes commentedComment #16
danillonunes CreditAttribution: danillonunes commentedAnyone has any idea of how this behaves in D8 now with the new toolbar?
Comment #17
danillonunes CreditAttribution: danillonunes commentedThis is not a issue in D8 with the new toolbar. Backporting to 7.x.
Comment #18
mgiffordThis works just fine.
Before:
After:
Comment #22
danillonunes CreditAttribution: danillonunes commentedGot a fatal error in OpenIDFunctionalTestCase->testBlockedUserLogin. I don’t think this has anything to do with this patch.
Comment #24
danillonunes CreditAttribution: danillonunes commentedYeah, it’s green now!
Moving back to RTBC as set by #18.
Comment #27
David_Rothstein CreditAttribution: David_Rothstein commentedComment #30
dcam CreditAttribution: dcam commentedComment #33
dcam CreditAttribution: dcam commentedComment #34
David_Rothstein CreditAttribution: David_Rothstein commentedWhen I apply this patch to a default installation of Drupal core, the shortcut bar stops working entirely. You can no longer collapse it (and in one case I'm pretty sure I was unable to expand it instead).
I would suspect it has something to do with this, since the code here looks totally wrong:
Also, it would be ideal not to mess with Drupal's cookies in the middle of a stable release; that is kind of part of the public API. Maybe there's another way to fix this still?
Comment #35
David_Rothstein CreditAttribution: David_Rothstein commentedThough I have to say that the idea of fixing it the way this patch did (switching up collapsed vs expanded checks) sounds pretty clever :)
Comment #36
danillonunes CreditAttribution: danillonunes commentedI wonder how I managed to make this work 2 years ago. :P
Probably something was lost with the backport from 8.x to 7.x. At the time the recommendation was to write patches to 8.x branch, but between the time I wrote my first and second patches a lot of things changed in the D8 toolbar.
Anyway I will check this later.
Comment #37
danillonunes CreditAttribution: danillonunes commentedDuplicated.