Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / outside_in / src / Ajax / OpenOffCanvasDialogCommand.php
index 9989d91f652745abb9cd4f84d3776d82c0feadb0..2371483ed531b847c9dbcd087c96f75dc12a190a 100644 (file)
@@ -11,6 +11,11 @@ use Drupal\Core\Ajax\OpenDialogCommand;
  */
 class OpenOffCanvasDialogCommand extends OpenDialogCommand {
 
+  /**
+   * The dialog width to use if none is provided.
+   */
+  const DEFAULT_DIALOG_WIDTH = 300;
+
   /**
    * Constructs an OpenOffCanvasDialogCommand object.
    *
@@ -42,6 +47,12 @@ class OpenOffCanvasDialogCommand extends OpenDialogCommand {
     // @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an
     //   empty set of buttons until https://www.drupal.org/node/2793343 is in.
     $this->dialogOptions['buttons'] = [];
+    // If no width option is provided then use the default width to avoid the
+    // dialog staying at the width of the previous instance when opened
+    // more than once, with different widths, on a single page.
+    if (!isset($this->dialogOptions['width'])) {
+      $this->dialogOptions['width'] = static::DEFAULT_DIALOG_WIDTH;
+    }
   }
 
   /**