Problem/Motivation
As part of #3343940: Field UI 2023 User Research, we discovered that users have challenges orienting themselves in the Drupal Admin UI. One of the many causes to this is that Drupal doesn't indicate active menu trail in the Toolbar when user navigates to pages that are deeper in the administrative UI. While this information is available through the breadcrumbs, to make users more confident about their orientation, it is important to communicate the current location using multiple mechanisms as described by this Nielsen Norman article about navigation.

Proposed resolution
Indicate active menu trail even for pages that are not included in Toolbar to help users orient in which section of the site they are currently on.
Remaining tasks
User interface changes
Top level: /admin/structure
HEAD:


MR:


Sub level: /admin/structure/types
HEAD:


MR:


Sub sub level: /admin/structure/types/manage/article/fields
HEAD:


MR:


API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #63 | Screen Shot 2023-08-28 at 12.35.31 PM.png | 103.17 KB | hooroomoo |
| #63 | Screen Shot 2023-08-28 at 12.35.21 PM.png | 176.53 KB | hooroomoo |
| #63 | Screen Shot 2023-08-28 at 12.32.54 PM.png | 99.94 KB | hooroomoo |
| #57 | MR-toplevel-vertical.png | 268.79 KB | hooroomoo |
| #57 | MR-toplevel-horizontal.png | 84.15 KB | hooroomoo |
Issue fork drupal-3371005
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3371005-toolbar-doesnt-indicate
changes, plain diff MR !4366
Comments
Comment #2
shailja179 commentedComment #3
shailja179 commentedThis feature is not working in other Drupal versions as well. For this we will have to enable the child links in toolbar as well.
Comment #4
lauriiiThanks @shailja179! That is indeed the current behavior. 😊 This issue is to address that bug. Hopefully we can find a way to indicate the active menu trail even when the child links are not in Toolbar.
Comment #5
tim.plunkettComment #6
omkar.podey commentedComment #8
omkar.podey commentedThe toolbar seems to be working as expected (The active trail is maintained through the menu even if we traverse deeper into feild settings) in vertical orientation but not in the horizontal one, they basically have different UI's so I don't think the same behaviour should be expected anyways.
Comment #9
omkar.podey commentedToolbarTest.php is just copied over and i used it to debug initially, might delete it completely or convert into an actual test.
Comment #10
omkar.podey commentedComment #11
omkar.podey commentedComment #12
omkar.podey commentedStill need to create an issue for broken breadcrumb under the
Appearancetab.Comment #13
omkar.podey commentedComment #14
shiv_sharma commented@omkar.podey PR does have 4 unresolved threads please resolve them,
Comment #15
omkar.podey commentedI'm unable to log in into gitlab as of now (just keeps redirecting me to the home page, when clicking signIn), hence the unresolved threads, but i have addressed all of it.
Comment #16
tim.plunkettComment #17
omkar.podey commentedComment #18
omkar.podey commentedI mostly caused this behaviour so closed #3376457: Change in orientation doesn't load collapsible icons until page refresh. and start fixing it here.
Comment #19
omkar.podey commentedComment #20
lauriiiI'm not sure if I'm doing something wrong, but I tried to take the MR locally and it isn't changing the behavior at all. Wondering if some of the changes broke this for Drupal instances that are not running in a subdirectory?
Comment #21
omkar.podey commentedThat's weird, I am not running drupal in a subdirectory it does seem to be working for me and other machines. Maybe just needs a drush cr.
Comment #22
omkar.podey commentedComment #23
tim.plunkettNote that in addition to clearing Drupal caches I also ran
sessionStorage.clear();localStorage.clear();in the browser console while testing this just to be sure. Works for me. Pushed a small clean-upComment #25
rajeshreeputraRebased and to apply patch locally.
Tested the same, I can see the current active menu trail. Nice work here. 🙂
Comment #26
smustgrave commentedTest failure seems legit to issue.
Comment #27
lauriiiIt looks like #20 is because I'm using Umami which is a multilingual site that uses a path prefix for detecting languages.
Comment #28
omkar.podey commentedComment #29
omkar.podey commentedComment #30
hooroomooThe bold and underline indicating the active tab is hard to see in my opinion. I think this could benefit from changing the background color to highlight it as well.
Current MR:

Suggestion of highlighted tab (#f5f5f5 is used in the screenshot for the active tab):

Comment #31
omkar.podey commentedComment #32
omkar.podey commentedComment #33
omkar.podey commentedi did try to change the highlight colour on the css file but it seemed to show no effect on my local, is there something that i'm missing?
Comment #34
hooroomoo#33 It looks like if on Claro, then
claro/css/state/toolbar.menu.pcss.cssis used so the bg color needed to be added thereComment #35
omkar.podey commentedComment #36
omkar.podey commentedComment #37
smustgrave commentedApplied the MR on an Umami install
Went to /en/admin/structure/types/manage/article/fields
But "Content types" doesn't appear to be highlighted.
There a step I'm missing?
Comment #38
omkar.podey commentedMaybe try
Comment #39
hooroomoo#37 should work now
Comment #40
smustgrave commentedRetested MR 4366 and on admin/structure/types/manage/article/fields I see that the "Content types" link is highlighted as expected
Woo!
Comment #41
hooroomooUploading static patch for 11.x. Please ignore this and continue further work on MR.
Comment #42
lauriiiPosted review on the MR
Comment #43
omkar.podey commented.
Comment #44
omkar.podey commentedThe problem right now is a line in
core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.jsnight watch js testDrupal.toolbar.models.toolbarModel.set('orientation', 'vertical');should have triggeredin
core/modules/toolbar/js/toolbar.jsand which should have the toolbar in vertical state but it doesn't.Comment #45
omkar.podey commentedComment #46
omkar.podey commentedComment #47
lauriiiConfirmed with @ckrina that the background change this issue is introducing is acceptable.
Comment #48
utkarsh_33 commentedLeft a comment suggesting a small change so marking it back to needs work.
Comment #49
lauriiiThanks for the review @Utkarsh_33! Addressed feedback 😊
Comment #50
omkar.podey commentedWhile reviewing I found a bug when the toolbar is expanded down
Configuration-->Developmentthe horizontal orientation button disappears and can't be scrolled down to but this can be a separate issue.Comment #51
omkar.podey commentedI think we should also test
Horizontal->Verticaland vice-versa that tests, the state is maintained properly after orientation change. Expanded the test coverage to cover this in the previous commit.Comment #52
omkar.podey commentedJust a bit concerned about
render()as we are always calling boththis.renderVertical(); this.renderHorizontal();but it does seem to work fine and the code is much simpler this way.Comment #53
omkar.podey commentedComment #54
wim leersThis logic exists in two places — let's extract it into a helper function? 🙏
Why this change? (Not yet explained on issue or MR AFAICT.)
AFAICT the
startsWithwill always be true due to presence of the base path.Shouldn't this be
instead? 🤔
🤔 The comment mentions "focus", but I don't see anything focus-related here?
👏
🤔 It's possible to add external links anywhere in a menu.How will this behave in that case?Let's add explicit test coverage. Chances are a number of sites are using that, and we want to ensure there are no JS errors in that case!Breadcrumbs can only ever refer to local/internal links! 👍
Comment #55
omkar.podey commentedComment #56
omkar.podey commentedRE Comment#54 / 4
I think we are majorly concerned with the
basePathrather thanpathwhich comes from a list of internal paths which is always relative I think but thebasePathis always absolute I guess so maybe we don't need the condition at all ?.RE Comment#54 / 3 and RE Comment#54 / 5
It's no more the case, based on a previous commit.
Comment #57
hooroomooComment #58
hooroomooAdded screenshots to IS of before and after changes with both vertical and horizontal orientations for top level (/structure), sub level (/structure/types) , and sub sub level (/admin/structure/types/manage/article/fields)
Comment #59
hooroomooI believe all the remaining feedback has been addressed or no longer applies. Tested and code looks good to me.
Comment #61
lauriiiPosted feedback regarding caching + how we could handle custom breadcrumb builders more gracefully. Crediting @catch for discussing this in Slack.
Comment #62
omkar.podey commentedComment #63
hooroomooIt looks like there was a regression somewhere because I am not getting the active tab anymore when I manually tested. I think the tests also need to be updated since it didn't catch the regression (left a comment).
Horizontal admin/structure/types on initial load not showing active tab

Vertical admin/structure/types/manage/article/fields not showing active tab

Horizontal admin/structure/types/manage/article/fields not showing active tab

Comment #64
tim.plunkettAccording to manually testing with git bisect, https://git.drupalcode.org/project/drupal/-/merge_requests/4366/diffs?co... is the offending commit.
Reverting that fixes things, but I'm not sure why @omkar.podey added that.
And as @hooroomoo points out, we're definitely missing test coverage
Comment #65
omkar.podey commentedComment #66
hooroomooFeedback has been addressed. Removing needs test tag. Looks good to me.
Comment #67
lauriiiOne more thread in the MR because we can probably get rid of the breadcrumb dependency with the latest solution 👍
Comment #68
hooroomooFeedback has been addressed
Comment #71
lauriiiCommitted 3165269 and pushed to 11.x. Thanks!