Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292776

Allow OffCanvas Dialog to disallow resizing

$
0
0

Problem/Motivation

In working on Same Page Preview, I have noticed that when a user resizes the off-canvas dialog by adjusting the left border of the panel, the javascript that drives how the the panel's width / proportions sometimes has errors. This problem was made worse by our choice to have a "full screen" button that programmatically sets the width of the panel to be 100%.

Instead of fiddling with the logic (that is also in core and would have to be overridden), I'd like to have the ability to turn resizing off.

I discover that it currently isn't possible because the OpenOffCanvasDialogCommand ALWAYS sets the jQuery driven dialog to be resizable.

With a small code change we could fix that.

Steps to reproduce

Create an off screen dialog like this:

$form['toggle_preview_link'] = [
      '#type' => 'link',
      '#title' => t('Launch preview'),
      '#url' => Url::fromRoute('same_page_preview.preview_pane', $route_parameters),
      '#attributes' => [
        'style' => 'display: none;',
        'class' => ['use-ajax', 'button','button--primary', 'visually-hidden'],
        'data-dialog-type' => 'dialog',
        'data-dialog-renderer' => 'off_canvas',
        'data-dialog-options' => Json::encode([
          'width' => '50%',
          'resizable' => false, // <= This option should allow the dialog to not be resizable
          'classes' => [
            // @todo figure out how to override more than just this one.
            'ui-dialog' => 'same-page-preview-dialog',
          ],
        ]),
      ],
      '#attached' => [
        'library' => [
          'core/drupal.dialog.ajax',
        ],
      ],
    ];

Proposed resolution

Add a conditional in OpenOffCanvasDialogCommand to see if the caller has provided a value for the dialog option, resizable. Use it instead of overriding that choice.

User interface changes

Allows off-canvas dialogs to not be resizable.


Viewing all articles
Browse latest Browse all 292776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>