Problem/Motivation

Navigation uses layout builder to define regions for content and footer. Currently you can place limited blocks into content, but footer is restricted. Modules like Environment Indicator, Workspaces(core) and Masquerade are examples of modules that may be useful to claim space in Navigation with more rigid placement. Most noteably for the scope of this issue, above the content region.

Navigation extendable region above content section

Proposed resolution

Add the ability for module developers to add integrations to a new content_top region that sits above the content region.

Provide hooks to easily extend the content_top region.

A potential follow-up issue could look at adding the same kind of extensibility to the footer region. The footer region is more sensitive from a design perspective to a big number of blocks that content region. Hence it needs further discusssion and is out of scope for this issue.

Remaining tasks

Write Change Record

User interface changes

Output content_top variable/slot in the template.

API changes

  • New hook navigation_content_top to define content_top blocks
  • New hook navigation_content_top_alter to alter content_top blocks

Release notes snippet

Added a content_top section to the navigation for programmatic additions

Issue fork drupal-3463142

Command icon 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

michaellander created an issue. See original summary.

michaellander’s picture

I'm still a bit conflicted, in that I think we should just allow modules to extend on the layout builder usage, and also allow users to add blocks to the navigation footer. However, I realize there's some hesitancy here, so we still should consider giving some means for modules to extend these areas.

m4olivei’s picture

Thanks for your work! It's great having your work on env indicator to get a look at the real world pain points in integration.

Adding a related issue around Navigation's extensibility. I'm not sure ATM if we want to merge the issues or keep both.

plopesc’s picture

Not sure if the aim of this issue is exactly the same, but discussion about Config Actions for Navigation has been opened in #3478224: Provide Config Action to add new blocks to navigation from recipes.

plopesc’s picture

Status: Active » Postponed

This issue has been discussed internally and for now it seems that we are going to rely on Layout Builder's capabilities to manage this.

#3478224: Provide Config Action to add new blocks to navigation from recipes Will give the possibility to modify the config using recipes, as this is the way to extend layout builder config is expected to use.

3rd party integrations without recipes might need the manual step of adding blocks to the navigation bar once the modules are installed.

amateescu’s picture

3rd party integrations without recipes might need the manual step of adding blocks to the navigation bar once the modules are installed.

If "manual" here means "the user has to do it", isn't that quite a regression from what was previously possible with hook_toolbar() and hook_toolbar_alter()?

amateescu’s picture

A bit more context for #6: in #3425081: Integrate Navigation with Workspaces I proposed a new hook_navigation_alter() hook that would provide a similar DX to the Toolbar module.

Was that option considered?

finnsky’s picture

plopesc’s picture

If "manual" here means "the user has to do it", isn't that quite a regression from what was previously possible with hook_toolbar() and hook_toolbar_alter()?

Yes, I agree.

Difference is that new navigation allows to modify the order of the sections through the UI, and it adds an extra layer of complexity that makes the automatic integration of new elements slightly more complex.

This issue was postponed because we currently have other priorities in the roadmap to convert Navigation into a stable module and integrate it with Drupal CMS. #3421969: [PLAN] New Navigation and Top Bar to replace Toolbar Roadmap: Path to Stable

A proposal for having 2 "toolbar" like sections for the navigation top and footer could be a possible approach. That would leave only the "content" region managed through LB.

Or provide a simpler API for adding Navigation blocks to the LB during module installation, that could be exported as config afterwards.

plopesc’s picture

Status: Postponed » Active

plopesc’s picture

Status: Active » Needs review

Implemented an initial approach to create a new "promoted" region in the Navigation bar that allow modules to place their content programmatically.

My initial feeling was to name it "top", but it could cause confusion with the top bar, so ended up using the "promoted" name for the section and the related hooks. I'm totally open to better naming suggestions.

Regarding the footer, given that's a region that already exists, this change might need more internal discussion. I'm more inclined to leave it out of the scope of this MR for now.

m4olivei’s picture

Status: Needs review » Needs work

Suggesting a different name of 'header' to go with existing 'content' and 'footer'. Let me know what you think.

Also, do we want to address the region just above the footer, which is asked for in the issue description?

Otherwise, I think this is a fine way to cover this requirement. It offers a lot of flexibility to module authors to put whatever render array they want there. To @finnsky's point he's been arguing for in various places, we'll have to flesh out our components more in order for module authors to author things that fit well in these spots.

m4olivei’s picture

plopesc’s picture

Status: Needs work » Needs review

@m4olivei Property renamed. Could you please take a look into this again?

Static tests are failing due to an unrelated issue in 11.x.

m4olivei’s picture

Status: Needs review » Needs work

Looking good to me!

The MR doesn't address footer_top? I'm wondering if there was a specific reason why not that I'm missing. We either need to add that in as well, or update the issue description to reflect only content_top being covered here. Marking as Needs Work for this reason, but not wanting to discourage integrations from leaving thoughts as well, so please do feel free to leave review comments.

plopesc’s picture

Title: Allow modules to hook into top of content/footer sections of new core navigation » Allow modules to hook into top of content section of new core navigation
Issue summary: View changes

Thank you for you review @m4olivei.

Footer is a more complex region than content and I would rather to discuss it in more detail in a follow-up issue.

Merging this one would unblock other integrations like Dashboard, Environment Indicator, Workspaces or Umami.

If you are OK with that, i think the only remaining step here would be to write the corresponding Change Record.

m4olivei’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new119.83 KB

Thanks @plopesc! That makes sense. Thanks for the updates.

I've written a draft change record.

Also, updating the description to remove one more reference to footer_top as well as updating the screenshot to reflect the actual implementation.

As we only bumped back to needs work on docs related issues, marking this all the way to RTBC!

m4olivei’s picture

Issue summary: View changes
m4olivei’s picture

Issue summary: View changes
ckrina’s picture

Adding the "Drupal CMS release target" to see if we could hopefully get to it.

ckrina’s picture

Adding the "Drupal CMS release target" to see if we could hopefully get to it.

michaellander’s picture

plopesc’s picture

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

plopesc’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC once conflicts have been solved.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

This looks good to me, just a couple of comments about the test - one about avoiding random failures we've only just found in the last week or so - and another about refining how we clear the cache

Will keep an eye out for the re-RTBC but feel free to ping me

m4olivei’s picture

Status: Needs work » Needs review

Thanks for the review. I've addressed the feedback. Back to Needs review.

penyaskito’s picture

Status: Needs review » Needs work
plopesc’s picture

Status: Needs work » Needs review
m4olivei’s picture

Assigned: Unassigned » m4olivei

Will play a bit and work out a solution to my comment.

m4olivei’s picture

Status: Needs review » Needs work
trackleft2’s picture

Not sure if it matters, but it was found that environment indicator module does not need this patch in order to integrate into the navigation module.
See https://git.drupalcode.org/project/environment_indicator/-/merge_request...

m4olivei’s picture

@trackleft2 correct!

However, the sub-module version of that issue hasn't received broad consensus per a read through of the issue. Also, both MRs require that the admin configure an additional Navigation Block via the UI. This patch will mean that's not necessary, it can be included via a hook and also be included in a consistent spot for all sites.

m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Needs work » Needs review

I ended up not liking the empty div. Instead, what I did was introduce a new #theme hook for content top to carry the cacheability metadata of empty items if present. This way we collect and render all necessary cacheability metadata, respect the API we set, and don't end up with empty divs.

I think this checks all the boxes, but I'm very open to suggestions.

Setting to NR in any case. Thanks!

trackleft2’s picture

I like the new approach, also, I've updated the change record to include OOP/attribute example for the hooks.

plopesc’s picture

Status: Needs review » Reviewed & tested by the community

Matt did a great job addressing the outstanding comments, so moving it back to RTBC.

larowlan’s picture

Issue credits

larowlan’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: -11.2.0 release priority

Committed to 11.x and backported to 11.1.x because we want to get Navigation to stable.

Setting to 10.5.x for further backport.

plopesc’s picture

Status: Patch (to be ported) » Needs review

Created new MR against 10.5.x

amateescu’s picture

Note that the commits from #39 were not pushed.

  • larowlan committed 7a37ca1e on 11.1.x
    Issue #3463142 by plopesc, m4olivei, larowlan, penyaskito: Allow modules...

  • larowlan committed 17b0403e on 11.x
    Issue #3463142 by plopesc, m4olivei, larowlan, penyaskito: Allow modules...
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems like a good re-roll for 10.5

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

plopesc’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC once conflicts have been solved.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

plopesc’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC. MR is still mergeable against 10.5.x.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

godotislate’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +no-needs-review-bot

Turning off the bot.

  • nod_ committed d93c93cc on 10.5.x
    Issue #3463142 by plopesc, m4olivei, larowlan, penyaskito: Allow modules...
nod_’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -no-needs-review-bot

Committed d93c93c and pushed to 10.5.x. Thanks!

michaellander’s picture

Edit: I can't give credit, but I also appreciate the others involved that were not tagged. This definitely helps unblock us elsewhere!

nod_’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.