Problem/Motivation
Background
It is currently possible that a toolbar is empty, i.e. that there is a link in the toolbar but no actual toolbar menu items are revealed when clicking on that link. This happens most prominently when granting users the access toolbar permission, but no access to any administrative pages. Then the "Manage" toolbar item will appear, but without any actual links.
The fact that this is currently the case is being discussed - and potentially fixed - over in #2135445: Toolbar displays Manage tab even if the user is not permitted to see it, but until that is resolved this constitutes a separate bug.
Problem description
When there is an empty toolbar tray, the orientation toggle is still displayed. It does in fact allow switching the orientation, but this is pointless as there are no menu items. Moreover, in (the default) horizontal orientation the toggle "floats" beneath the toolbar where the tray would usually be displayed - except that there is no tray, only the toggle.

Steps to reproduce
Grant a user only access to access the toolbar, nothing more.
Proposed resolution
Don't add the orientation toggle if there is no tray.
Remaining tasks
User interface changes
The toolbar toggle is no longer erroneously displayed for empty trays.
API changes
-
Data model changes
-
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3257504-6.patch | 3.56 KB | tstoeckler |
| #2 | 3257504-2-tests-only.patch | 1.98 KB | tstoeckler |
| toolbar-tray-empty-orientation-toggle.png | 316.33 KB | tstoeckler |
Comments
Comment #2
tstoecklerHere we go. We manually append the orientation toggle, so simply appending it to the tray menu fixes this bug, as that will not happen if there is no menu. Added a little test as well and attaching a tests-only patch to prove the test's validity.
Comment #4
nod_Comment #5
nod_Fix is reasonable, it's mostly on trays with menus that happens so it works to check for the menu class.
It does change the source order a little (in the case of the shortcut tray) would be best to make sure we get the same source before/after the patch.
Comment #6
tstoecklerGood catch! I had totally missed that and you're absolutely right that we should not be changing the markup here. This one should be better.
Comment #7
gábor hojtsyLooks good, does not change the selected element now. Good find!
Comment #10
lauriiiCommitted 0c2677b and pushed to 10.0.x by locally re-compiling the JavaScript. Committed the patch to 9.4.x. Thanks!