Problem/Motivation
From the initial prototype tests and design explorations we've discovered that we need a new top section where we'll place several contextual elements.
Proposed resolution
We want to create a new top bar that will hold actions related to the existing elements on the working area or page being visited (since it will be shown in the front-end too) like the Local Tasks in the entity form or full view mode page. Because of that, if this top area doesn't have any content, it shouldn't appear.
This new top section or region won't be shown in the Block Layout for site builders to place content in. The elements shown in there will be placed only by code, which we should make available and extensible by contributed modules so they can improve and integrate more feature.
Remaining tasks
The implementation of this has started back-porting the Control Bar component from the prototype built in #3398483: Create a functional prototype of the new top contextual bar. For now it only has the region and its styles (scripts or anything else).
(we are here >)
- The next step here is to define the implementation strategy: should it be a region, a group of blocks or something else completely? Keep in mind that different elements will appear on different pages like local tasks and actions.
- The local-tasks in entity forms like Content nodes and Taxonomy terms need to be moved into the Top Bar.
- Add a form under Configuration > User Interface. Add a Checkbox there that, when enabled, the Top bar will be printed. When disabled, the Top Bar won't be printed. The default state should be disabled, so we can keep working on this as an experimental functionality without breaking any admin UI.

Latest design exploration for the top bar. Please ignore the design for the sidebar since it's just a design exploration happening under the Layout redesign efforts.

| Comment | File | Size | Author |
|---|---|---|---|
| #46 | topbar-DOM.png | 405 KB | akshayadhav |
| #38 | top-bar-after-fontfamily-change.png | 303.12 KB | akshayadhav |
| #38 | top-bar-before-fontfamily-change.png | 303.25 KB | akshayadhav |
| #32 | mixture_of_fonts_and_sizes.png | 271.49 KB | m4olivei |
| #32 | inherits_site_font_family.png | 732.92 KB | m4olivei |
Issue fork navigation-3402046
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:
Comments
Comment #2
finnsky commentedGonna work on it.
Comment #3
finnsky commentedBackported minimal MR for control-bar.
Comment #5
ckrinaThanks @finnsky for giving a first round to this! I like the approach the front-end code is taking, but adding a top bar without anything on it wouldn't make this useful on the module. If we merge something, it should already add some value. I'd recommend to add as a requirement at least to print the breadcrumb and/or the go back link here.
Also, I see this is adding the permission
'access toolbar', which is basically relying on the old toolbar. This should be created in this module for this module, no?I think both part 1 and 2 should happen in this issue, or at least a first approximation to step 2?
Comment #6
finnsky commentedIt still need some backender work. Added couple of TODOs. Please take a look
// TODO: Add special suggestion for only navigation module breadcrumbs
// To avoid suggestion attachment for page breadcrumbs.
// Also hide page breadcrumbs for Claro only.
Comment #7
finnsky commented@ckrina could you please add info about breadcrumbs here? When it will decided.
Comment #8
ckrinaWe're having the recap meeting after the tests today. I'll post as soon as I know something else. But regardless the breadcrumb, the top navigation will still be needed. So the back-end planning could still move forward.
Comment #9
ckrinaComment #10
ckrinaUpdated IS to reflect the needs of this task.
Comment #11
ckrinaAdding some images to make it easier to understand the idea.
Comment #12
ckrinaDefining the content this issue should actually introduce: not breadcrumbs, yes local tasks in entity forms like Content nodes and Taxonomy terms.
Comment #13
ckrinaComment #14
ckrinaUpdating the IS with a more recent design and adding some more details.
Comment #16
finnsky commented@Prashant.c
I think you should not apply changes from prototype branch as is.
It has a lot of quick hardcode solutions.
Comment #17
prashant.cWhile working on this issue, I identified additional tasks that require attention. Let's discuss the following points:
Thanks
Comment #18
finnsky commentedAfter rebase new css should be checked in terms of font-weights and new variables names
Comment #19
ckrinaGood questions @Prashant.c!
I would say that it would be better if we can avoid adding permissions if we can handle visibility in a simpler way: if the user doesn't have access to anything printed there (aka the array/whatever value the content goes is empty), then it won't be printed. My concern is that for example we move the Save button there and then a user could not have access to it. But if somebody has a good reason for this I'm missing let's discuss it!
Yes, but we're still researching what's the best way to properly print the HTML in a way that is accessible. That's why this issue just needs to focus on the local tasks for now.
As mentioned in 1, I'd try to keep the configuration at a minimum.
Comment #20
ckrinaI just installed this locally and there are a few things that would need to change:
1. Breadcrumbs shouldn't be printed on the Top Bar anymore. The work done by @finnsky adding/moving the breadcrumbs should be removed from this issue (sorry @finnsky!)

2. If the Top bar doesn't have any content to print, it shouldn't be printed.

The way to control if the Top Bar is printed (when there is content to be printed, as in the node form) should be the form mentioned in the issue summary, instead of permissions.
@Prashant.c if I've solved all your questions.
Comment #21
prashant.c@ckrina,
/admin/config/user-interface/navigation/settingsfor the module, including a "Hide Control bar" checkbox.It would be really helpful if someone can review the code.
Thanks!
Comment #22
prashant.c@penyaskito
Appreciate your review. I'd like to address your comments below:
Please let me know if I've addressed your concerns.
Thank you.
Comment #23
m4oliveiLeft some review comments.
The MR also needs to have some merge conflicts resolved. Also, it would be nice if Tugboat would build a preview here. Anyone aware of why it isnt' by chance?
Comment #24
prashant.cTried to fix some points from the MR review comments, I am also not sure why Tugboat preview not showing on the issue even if it has all the required files for it.
Comment #27
m4oliveiSure @Prashant.c I'll work on it and push a commit. Stay tuned.
Comment #28
m4oliveiOK, I've done the refactoring that I was suggesting in my MR coments. As well as a couple of other things along the way:
includes/html.inc, put logic back intonavigation.modulehook_preprocess_htmlandnavigation_local_tasksinto a new\Drupal\navigation\NavigationRendererclass$variables['page_top']in the preprocess function, I moved us to using the more targettedhook_page_top. I had to adjust the ordering with ahook_module_implements_alterimplementation so that we can run after toolbar module and remove it.#accesskey was lost. This was causing a broken navigation to show up for anonymous users. I added it back, and also added it to the control_bar render arrayStill work to do here from @larowlan review comments. Will pass that back for @Prashant.c or others.
Comment #29
prashant.cAdded cache contexts to fix the caching issue and did a minor code refactor.
changing status the status NR.
Comment #30
finnsky commentedI did quick check. We need to show control bar on mobile still
It has button expand/collapse sidebar https://gyazo.com/3f308319bb1897a105fc6315c4654819
Comment #31
finnsky commented@ckrina please take a look at #30
It needs decision. We cannot hide control-bar. It needed on mobile for expand button.
Or we can be some attribute. Like `empty-region` to just hide this bar on desktop when nothing rendered.
Comment #32
m4oliveiLeft a couple of MR comments. Also, noticed that there is some font discrepancies when the control bar is showing on the front-end of the site. I'm assuming the styles should be adjusted to follow the font styles of the
--admin-toolbar-*CSS variables so the font styles of the control bar are consistent with the navigation bar?Otherwise this is looking pretty good to me. So close!
Comment #33
prashant.c@m4olivei
Thanks again for a review. Addressed the review comments.
1. I agree font family and size etc. needs to be fixed in the Top bar.
2. Queries in https://www.drupal.org/project/navigation/issues/3402046#comment-15372914 still needs response from @ckrina.
Keeping it in NW for above.
Thank you.
Comment #34
ckrinaAfter today's discussion on the weekly meeting we mentioned this needed the following changes:
Feel free to coordinate and some people can take the back-end work and some other the front-end, so this way when we merge this it will be a fairly complete feature.
Thanks all for the work!
Comment #35
m4oliveiI'm going to resolve the merge conflicts on this branch, and take a crack at point 2 from #34.
Comment #36
m4oliveiFinished a couple of things:
From prior reviews, there is one item that is still outstanding, @larowlan's comment regarding cacheability metadata. I can try to address that tomorrow if no one else beats me to it.
If would also be nice if someone with access could close and re-open the MR so that we can trigger a Tugboat build.
Comment #38
akshayadhavAdded Inter as font family for top bar.
Before:

After:

Comment #39
finnsky commented@AkshayAdhav i think you should add that font to .toolbar-button globally, not in context of `control-bar`
Comment #40
akshayadhavOk @finnsky. Let me check again.
Comment #41
m4oliveiMore updates, in summary:
Along the way I noticed a couple of things:
access toolbarpermission. Should we be using the toolbar module permission? I think we've also said that we need the control bar for mobile anyway, should this even be conditional on a permission at all?Comment #42
ckrinaYes, but we don't have designs for it yet. I'd say it can be done in a follow-up.
If we are reusing the top bar for the toolbar on mobile, I don't think it's crazy to tie it to the toolbar? I mean, we'd understand this 2 bars as part of the same UI? But I'm not sure what could happen in the future though, like having users with access to local tasks but not to the sidebar navigation.
The reason is that we called Control bar the area we used to open/close the sidebar on mobile. Agreed on moving to use only one: I'd say Top bar is fine since it'll be always on the top. But I'd love to hear what @finnsky thinks.
Good catch! There is no issue for this yet.
Comment #43
m4olivei👍
OK cool. I agree. If it becomes an issue, easy enough to change down the road.
OK, I'll put it on my list to file a follow up issue here.
Comment #44
m4oliveiI've filed an issue for addressing the issues with limited access users #3413786: Icons display for items that a limited access user does not have access too.
Also sounds like we're in a review state, so updating status.
Comment #45
finnsky commentedComment #46
akshayadhavHi @finnsky
I wanted to push the code changes but facing some issues while rebasing the branch with
1.x. Will try again tomorrow.Regarding the change you requested which needs globally:
.toolbar-button { font-family: var(--admin-toolbar-font-family); }, for.toolbar-buttonclass, the font family is already set. Also, the top bar and admin toolbar fall under different divs, so we have to explicitly set the font family to top bar.Comment #49
m4oliveiNow that #3411099: Create an administration UI for managing Navigation Blocks is resolved, this MR has a boat load of conflicts.
I'll go through and resolve these.
Comment #50
m4oliveiI've resolved the merge conflicts. I've also done the renaming from "control bar" to "top bar" in places in code that were inconsistent as per #42.
I'll unassign from me, but leave as Needs work, given ongoing unresolved threads between @finnsky and @AkshayAdhav.
Comment #51
finnsky commentedGonna work on it
Comment #52
finnsky commentedCorrected the fonts. I leave the task for work because It still need to always display top_bar.
Perhaps we can use the :has selector here.
https://developer.mozilla.org/en-US/docs/Web/CSS/:has
For example
Or we may create `top-bar__content` inner. and when it is empty hide it with :has and :empty combination
https://developer.mozilla.org/en-US/docs/Web/CSS/:empty
Comment #53
plopesc@m4olivei Took a look into your latest changes and overall looks good.
Added some comments. Please take a look and share your thoughts about them.
Comment #54
m4oliveiFinished reviewing changes. Left comments in the MR.
Comment #55
finnsky commentedGonna add dummy button for open tollbar mobile. Just as temporary solution until we not decide what to do with it.
Comment #56
finnsky commentedComment #59
finnsky commentedComment #60
m4oliveiBack-end code looks all good to me! @plopesc, we'll want to file a follow up issue to address the code quality issues around dependency injection.
From a front-end, integration perspective, the hold-over solution for mobile works as advertised. I'll leave @ckrina to give the final thumbs up, but this is RTBC for me.
Comment #61
finnsky commentedWow! Great. This is huge step forward! Thanks everyone!
Comment #63
finnsky commentedComment #64
finnsky commented