Change record status: 
Project: 
Introduced in branch: 
8.5.x
Introduced in version: 
8.5.0-alpha1
Description: 

In addition to the two existing core dialogs, the regular dialog and modal dialog, there is now a third dialog available, the Off-Canvas dialog. This dialog comes in from the side of the page and adjusts the width of the page so that the dialog does not cover any of the current page.

Here is example of how it looks in action.

Creating Off-Canvas links

Creating links that open in the off-canvas dialog is very similar to creating links that open the existing dialogs.

$my_link =[
        '#title' => 'Click Me!',
        '#type' => 'link',
        '#url' => Url::fromRoute('off_canvas_test.thing2'),
        '#attributes' => [
          'class' => ['use-ajax'],
          'data-dialog-type' => 'dialog',
          'data-dialog-renderer' => 'off_canvas',
        ],
        '#attached' => [
          'library' => [
            'core/drupal.dialog.ajax',
          ],
        ],
      ];

The only difference is the need to specify 'data-dialog-renderer' => 'off_canvas'.

Example Off-Canvas links can be found in the off_canvas_test test module in core.

Markup changes

To facilitate resizing the page contents to show the off-canvas dialog there is now a new <div> element wrapping the page element. The markup for this element is controlled by the off-canvas-page-wrapper.html.twig template file. This template adds an attribute data-off-canvas-main-canvas to the div which should not removed without breaking the off-canvas dialog JavaScript (the template has a warning about this).

AttachmentSize
Tray animation732 KB
off-canvas select list issue.png29.2 KB
Impacts: 
Site builders, administrators, editors
Module developers

Comments

Leagnus’s picture

when i insert custom div in page.html.twig right before </header>
in result DOM i have the div outside <div class="dialog-off-canvas-main-canvas"
i.e. outside <header>
though settings_tray module isn't enabled.
So in this case everyone should do it by js on $(document).ready event.

quietcorn’s picture

My problem is that I'm using views to produce some custom RSS feeds and XML files, and now I have the dialog-off-canvas-main-canvas div enclosing it, thereby invalidating my feeds. I've tried doing URL specific template overrides, but it doesn't seem to allow for that. Not sure what to do.

mingsong’s picture

Thanks for the great feature.

Just raise an issue with Bootstrap theme.

Apparently, Bootstrap theme has its own dialog.ajax.js file that is the same name as core/drupal.ajax (/core/misc/dialog/dialog.ajax.js).

I am not sure if it is a problem, but I couldn't get the feature working with Bootstrap theme (https://www.drupal.org/project/bootstrap).

tmwagner’s picture

There is no Bootstrap 4 (yet - even though BS 4 has been around for a long time AND BS3 is pretty lame compared to BS4).

Or, is the issue with integrating Bootstrap (either 3 or 4)? I'm using Barrio and loading BS4 with that.

mingsong’s picture

The select list overflows while it is too long.

See the screenshot.
Select list overflow

mxt’s picture

Why is the wrapper always printed in page even if the Settings Tray module is disabled?

I think this `off-canvas-page-wrapper.html.twig` should be activated only if its Settings Tray module is activated. Or only under specific user permissions (e.g : only for editors and not anonymous for example).

I was developing a theme with the main layout grid based on flexbox and its layout has broken when I did the upgrade from 8.4 to 8.5 just because the new wrapper div has appeared from scratch! Does an official communication about the risk of potential themes breakdown has been written somewhere?

vayu’s picture

The solution for one of them was to add to my global stylesheet:

.dialog-off-canvas-main-canvas {height: 100%;}

The other theme I hadn't figured out this fix yet and what I did is in several places where I had heights set as % units, I changed them to vh units.

MXT you're not alone, it was pretty frustrating for me as I had a deadline to show the theme I was working on and I had to spend time investigating and fixing something that was working perfectly well.

alison’s picture

This was a frustrating issue for us, to me.

Sincere question: Why is it there when the aforementioned module is disabled?

imperator_99’s picture

Not only that, why is it there for non-administration themes?

gaborkurucz’s picture

This is the question I'm asking myself also... I have the same issue, I don't want a wrapper div around page render, especially not in non-admin themes.

gaborkurucz’s picture

https://api.drupal.org/api/drupal/core%21modules%21system%21system.modul...

The last couple of lines in the system.module file.

I removed it with a custom hook_element_info_alter() (which feels like a very hacky workaround/reset) but I find it a bad practice to force this on themes/sites that don't want to use it.

penance316’s picture

agree with this.

this has just caused an issue with our installation set to auto updated non-breaking changes.
This will be tough to explain to the higher-ups why a non breaking change has broken something

tmwagner’s picture

Creating links that open in the off-canvas dialog is very similar to creating links that open the existing dialogs.

Awesome! This could be great tool if it was documented somewhere. Why isn't there a scrap of documentation on the Dialog API.
According to this tutorial, the "Dialog API" is now in core. Creating a modal in Drupal 8

A very simple yet functioning example is given... But, where are the docs?

whereisaaron’s picture

While I appreciate the new feature, this is a breaking change for many themes.
Breaking changes should have been thought through, documented, and mitigated, considering the detrimental impact on others.

Anoesj’s picture

Not okay to suddenly put an extra wrapper around everything. First thing I did was take it out again. Thanks a lot for wasting my time.

cb_dewr’s picture

This change record is for 8.5!? There is a lot of useless noise on the list by publishing change records for unsupported versions.