Problem/Motivation
In #3397058: Convert navigation sections to blocks and use the menu system we created a new Navigation Section (renamed here to 'Navigation Block') plugin type as a new concept to encompass things that go into the Navigation toolbar. Navigation Block plugins are block-like, inheriting much of the same behavior of blocks. They are a unique concept as a way of distinguishing and not inheriting everything that is a block today.
We need the ability for site administrators to manage the Navigation Block plugins that live in their navigation toolbar in the same way they would manage what blocks live in the defined regions of their site.
Proposed resolution
In no particular order, this would require, but no limited to the following:
- New admin UI mimicing the Block layout UI (/admin/structure/block). Presently, we only need to allow administration over the 'content' area of the Navigation toolbar.
- New config entity that mimics the block config entity
- Default install the necessary config entities to keep the Navigation toolbar elements that we currently have
Remaining tasks
Manual testing. To test:
- Turn on the navigation module
- Navigate to Administration > Configuration > User interface > Navigation blocks
- Reorder navigation blocks
- Place a new navigation block
- Edit existing navigation block
- Remove navigation block
- Disable navigation block
- Enable navigation block
- Play with visibility conditions
Break it! Then report it.
Also needed:
Refactor Javascript introduced without jQuery. Follow up: #3412125: Convert jQuery to vanilla Javascript.Discuss (from #13): Contextual links, yay, nay, or hide for now and follow up issue. Removed here. Follow up: #3412116: Add contextual link for the whole Navigation bar to link to the Navigation Admin UI.Discuss (from #13): "Reset to default" in navigation layout settings?. Follow up: #3412123: Revert to default in navigation layout settings from the UI.Rename "Navigation section". Current leading contender "Navigation block".- Much back-end code review.
User interface changes
A new Admin UI, like the Block layout UI, for managing Navigation Blocks.
Data model changes
New navigation_block config entity
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | Admin-section-placed-in-footer.png | 204.9 KB | prashant.c |
| #14 | Title-not-updated.png | 105.04 KB | prashant.c |
| #7 | Navigation-section-menu-item.png | 23.19 KB | prashant.c |
| #7 | Navigation-section-list-builder.png | 111.3 KB | prashant.c |
| #7 | navigation-section-edit-entity.png | 97.63 KB | prashant.c |
Issue fork navigation-3411099
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
m4oliveiI'll prototype this over the next few days.
Comment #3
m4oliveiComment #4
prashant.c@m4olivei
Awesome! Eagerly anticipating this; I hope to make a meaningful contribution here too. :)
Appreciate it.
Comment #6
m4oliveiI got to a good stopping point, so I thought I would post the MR. It's not done yet, but many of the back end pieces are put in place here, including (not exhaustive):
Still to do:
Will keep working on these tomorrow.
Comment #7
prashant.cCould not find the link to open the entity page therefore added code for the following:
1. Added the collection route for the entity
2. Added links file
Will keep testing.
Thank you.
Comment #8
m4oliveiThanks for testing @Prashant.c.
As I noted in my previous comments, I'm still actively working on the issue. The default list builder came along with the drush generate command when I initially ran it to get a start on the config entity. We won't be using it, as we're going to create a UI like blocks (with "Place Navigation Section" buttons, dialogs, etc.).
I'll note clearly in comments when I'm done with the initial work and at that time will unassign and invite further commits. It's good to avoid duplicate effort. Thanks!
Comment #9
prashant.cThanks, @m4olivei! I didn't notice that you had already assigned it. Nevertheless, I'm looking forward to exploring the features, especially the "Place navigation section." Cheers!
Comment #10
m4oliveiMore commits!
I've fleshed out most of the back-end pieces for the Navigation section layout admin UI. You can now:
Several caveats at this point:
I'm continuing to work through open issues.
Comment #11
m4oliveiI'm at a good stopping point now. I'm going to unassign and set to Needs review.
From #6, I've finished:
navigation_section list_builder handler evaluation. Might not need this, came with drush generateFlesh out the admin UI on top of all the data layer implementation. Keep an eye toward allowing a future for multi-region management, but we only need content region management for now. I decided to keep content and footer region management. Good for testing, also, seems feasible that some users may prefer their shortcuts in the footer, which totally works.Make sure contextual region / menu stuff works as expectedMuch testing. More needed!From #10, I've finished:
Any functionality depending on Javascript, I haven't gone through yet. Filter mechanism on the navigation section libary dialog is one example.Visibility settings don't get used yetNot sure if exposing the 'Category' in the UI is useful? Probably worth it, who knows how this would get implemented, maybe many plugins would proliferate in contrib.Additional notes.
From #10:
This is still true, but would be an issue for a followup ticket. It works now to do this. We can talk about theming considerations / restrictions in a followup.
From #10:
I thought about this. Category will probably be useful. By default it comes from the module providing the NavigationSection plugin, hence they are all showing as "Navigation". I can imagine a future when this gets into core where the User NavigationSection goes into the user module, the Shortcuts NavigationSection goes into the shortcut module, etc. Plus contrib and it will be useful to have and display. I left it in.
Also, a note about contextual links. I fixed them in a recent commit, so that, like blocks you can use it to get to the edit form or remove a navigation section placement. The front end UX is very awkward though. There will be front-end work to do here to get it all sorted. Would be a good follow up. Maybe we hide it in this MR, with the intent to unhide and fix the UX in a follow up.
Any feedback on functionality or code review is very much welcome.
Comment #12
m4oliveiComment #13
finnsky commented1. i don't really think that contextual links should be added. This is mostly admin menu. It is kind of annoying action for 99% of users who don't want to use anything except default navigation blocs layout.
https://gyazo.com/47492d4feda61a3b2f8a54b4c39ad4d6
2. I don't want jQuery appear in new core code.
https://www.drupal.org/project/drupal/issues/3052002
I would better rewrite it with vanilla js.
Gonna work on it in next few days.
3. Probably we need to have button "Reset to default" in navigation layout settings? I guess can be much more blocks in future. Unexperienced users easy can break all site controls.
Keeping this issue in `Needs review` for backend/UI review.
Comment #14
prashant.c1. I concur that there should be a "Reset to Default" button available on
/admin/structure/navigation-sectionfor resetting the navigation section. This feature is essential in case users or admins inadvertently modify the settings and wish to revert to the default state. Currently, this option is unavailable, and having it would be a valuable addition.2. Despite updating the section title in the backend, the displayed title remains unchanged. Refer to the image below for clarification:
3. There is an issue with the scrolling functionality when the "Administration" section is positioned in the footer. The navigation bar does not scroll due to an overlap problem, and no scrollbar appears. Please see the image below for a visual representation:

Changing IS to NW.
@m4olivei, excellent job!
Comment #15
m4oliveiI tend to agree with you. When @ckrina and I originally discussed this, we said lets include contextual links, but yeah... now that I see it, it's problematic. Let's see what @ckrina thinks when she has a minute to review. I'm leaning towards excluding contextual links, or at least hiding it here for now and addressing the UX in a follow up in order to be able to include them.
Yep! This Javascript was copy pasted from core's block code hence why jQuery came along for the ride. We can for sure rewrite to avoid jQuery.
Perhaps? Although I'd arguee for most users, they wouldn't venture into the admin UI to adjust anything here, especially if we remove contextual links. Not sure it's worth the effort.
Comment #16
m4oliveiNice catch @Prashant.c. I've fixed that in the last commit.
Yeah, there will be dragons when placing things outside their intended place. This is a front-end issue and outside the scope here. We can talk about restrictions we may or may not want to place here. Adjusting styles to cope with more flexible placement would be out of scope here and a good candidate for a follow up.
Comment #17
m4oliveiUpdated issue summary with more remaining tasks based on discussion.
Comment #18
prashant.c1. The issue mentioned in Point 2 on https://www.drupal.org/project/navigation/issues/3411099#comment-15378332 has been resolved.
2. The remaining two points pertain to frontend issues.
3. Should we consider treating the conversion of jQuery to JS as an independent task for the entire module?
4. Currently, it seems that decisions regarding "Reset to default" and "Contextual links" are the only outstanding matters.
Overall, looks good to me.
Comment #19
ckrinaI’ve just manually tested it and it’s really cool seeing this working :D
1. We should restrict this, yes. Either in here or in a follow-up, I don’t mind. The more important reason is the Usability problem it opens because a huge bottom region will the difficult to use in different breakpoints. Plus it’s supposed to be a “complimentary” and less important region with the main purpose to give the open/close functionality in desktop: this functionality disappears on mobile and the footer stays at the bottom with only the almost no used User menu.
2. Location of the UI: it just go into Configuration not Structure. It’s a UI to change of an administration UI, not the structure of the site being built. I’d recomment movig this to Configuration > User Interface > Navigation sections.
3. Contextual links. 100% agree with #13. But there should be a quick way to get to the UI to manage this. Maybe a link or something like that. But I’d leave that for a follow-up.
4. Agreed on keeping it. In the future maybe other kind of custom block could be available, like the bar Umami adds to say it’s a testing site.
5. From #13. I’m not sure about this being a need: this pattern doesn’t exist on the Block Layout UI nor in the menus themselves, and showing a button for that you should clearly explain what will change to, what is in the defaults first. Plus it can actually be a disruptive change for whoever click in there. I’d say this lays into the responsibility of whoever has given the permission to a user?
What about trying to solve this potential stressing situation for newbies with proper module documentation in Drupal.org and maybe linking it with something like “See the recommended defaults”? Either way I’d move this to a follow-up too.
6. From #18.3. It would be great to not introduce any jQuery at all, but happy with it happening in a follow-up.
7. Why is it called “Navigation section” and not “Navigation block”? I find it confusing since I expect a region as a place to put several blocks if we rely in "Drupal terminology".
8. If you leave the Footer region without menus you loose the capacity to collapse the sidebar because the Collapse button disappears.
Comment #20
finnsky commentedProbably it can be one contextual link in top of sidebar? in logo region.
Comment #21
m4oliveiGreat feedback. I will work on these items this morning.
Comment #22
m4oliveiWe met this morning to discuss the remaining items here. In summary:
We will create follow up issues for the following:
Work to do in this issue
Move the ‘navigation sections’ link from the Structure parent link to the Configuration parent link. Done in 9c93a9f7.Comment #23
m4oliveiComment #24
m4oliveiComment #29
ckrinaWe discussed this with @lauriii: he suggested that we better go with "Navigation block" instead of components because he foresees conflicts and misconceptions with the components word the way it is used in Drupal. So let's go with "Navigation blocks" and unblock this issue :)
Comment #30
m4oliveiMade changes to issue title and description to reflect new "Navigation Block" language.
I've made the change to rename "Navigation Section" to "Navigation Block" in the code. Ready for review.
Comment #31
m4oliveiThanks @plopesc! I'll get to work on those straight away.
Comment #32
m4oliveiFixes made! Please review.
Also see my comment in the one open thread. Let me know if your OK with that.
Thanks @plopesc!
Comment #33
plopescThank you for taking your time to address the feedback! Code looks good to me, also played with the TB environment and I didn't found any remarkable issue.
Only open point would be the automated tests, but I don't know how you plan to address them.
Comment #34
m4oliveiThanks @plopesc!
I think with both @plopesc and @Prashant.c's reviews and all threads resolved, this is good to go.
Marking as RTBC.
Comment #36
ckrinaMerged. Great work!! 🙌🏼