Specify the page wrapper and override output

Created on 31 October 2021, over 2 years ago
Updated 3 November 2023, 8 months ago

Problem/Motivation

Currently there is no control over where the mmenu HTML is output. It is printed using hook_page_bottom. When mmenu is instantiated and no selector is provided it automatically creates a wrapping div for the page. This in turn causes a clash with the toolbar module so the toolbar is re-positioned in overridden JavaScript. This also causes a clash with the Gin layout builder module which has it's own toolbar.

If a developer/themer knows what they're doing they could specify their own mmenu HTML using the module provided functions and they can also specify the element which mmenu should consider the page wrapper and therefore not produce its own automated wrapper. This could be made easier and documented.

Steps to reproduce

Enable Gin layout builder and responsive menu module. Note that when editing a layout the top menu is not visible. Uninstall responsive menu module and edit a layout and note that the top menu is now visible.

Proposed resolution

1. Move the bulk of the code out of hook_page_bottom and instead provide a function or method which produces the render array ready for a developer to add to any region or page. Alternatively (or additionally) provide a block that can be placed.

2. Add an option in the module's configuration to disable the toolbar override and skip the automatic render array generation in hook_page_bottom.

3. Add an option in the module's configuration to specify the page wrapper using the offCanvas configuration option, in particular the selector attribute. See https://mmenujs.com/docs/core/off-canvas.html

✨ Feature request
Status

Needs review

Version

4.4

Component

Code

Created by

🇮🇹Italy tanc Italy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States mortona2k Seattle

    What about .dialog-off-canvas-main-canvas?

    It is added to the page element via a theme wrapper, in system.module, and wraps the page template in a class. We are adding .responsive_menu_page_wrapper to page in an html preprocess in responsive_menu.module. This appears to clobber the .dialog-off-canvas-main-canvas class.

    Would it be appropriate to use Drupal's off canvas setup instead of coming up with our own?

  • 🇮🇹Italy tanc Italy

    As this module is wholly built around a 3rd party library called mmenu there definitely aren't the resources and/or desire to port any of that code to Drupal's off-canvas system.

    However the issue of Drupal's off-canvas getting clobbered by our preprocess is definitely an issue to be resolved.

  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • 🇺🇸United States KarlShea Minneapolis, 🇺🇸

    Reroll from #6

Production build 0.69.0 2024