Issue #2828912 by tedbow, RajeevK, tim.plunkett, a-fro: Offcanvas width is not reset if tray is open with different width and not closed
parent
643e4b8a31
commit
359663bfdb
|
@ -11,6 +11,11 @@ use Drupal\Core\Ajax\OpenDialogCommand;
|
||||||
*/
|
*/
|
||||||
class OpenOffCanvasDialogCommand extends OpenDialogCommand {
|
class OpenOffCanvasDialogCommand extends OpenDialogCommand {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The dialog width to use if none is provided.
|
||||||
|
*/
|
||||||
|
const DEFAULT_DIALOG_WIDTH = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an OpenOffCanvasDialogCommand object.
|
* Constructs an OpenOffCanvasDialogCommand object.
|
||||||
*
|
*
|
||||||
|
@ -42,6 +47,12 @@ class OpenOffCanvasDialogCommand extends OpenDialogCommand {
|
||||||
// @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an
|
// @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an
|
||||||
// empty set of buttons until https://www.drupal.org/node/2793343 is in.
|
// empty set of buttons until https://www.drupal.org/node/2793343 is in.
|
||||||
$this->dialogOptions['buttons'] = [];
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,6 +46,7 @@ class OffCanvasDialogTest extends AjaxTestBase {
|
||||||
'draggable' => FALSE,
|
'draggable' => FALSE,
|
||||||
'drupalAutoButtons' => FALSE,
|
'drupalAutoButtons' => FALSE,
|
||||||
'buttons' => [],
|
'buttons' => [],
|
||||||
|
'width' => 300,
|
||||||
],
|
],
|
||||||
'effect' => 'fade',
|
'effect' => 'fade',
|
||||||
'speed' => 1000,
|
'speed' => 1000,
|
||||||
|
|
|
@ -63,7 +63,11 @@ class OffCanvasTest extends OutsideInJavascriptTestBase {
|
||||||
$this->assertEquals('', $header_text);
|
$this->assertEquals('', $header_text);
|
||||||
|
|
||||||
$style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
|
$style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
|
||||||
self::assertTrue(strstr($style, 'width: 555px;') !== FALSE, 'Dialog width respected.');
|
$this->assertTrue(strstr($style, 'width: 555px;') !== FALSE, 'Dialog width respected.');
|
||||||
|
$page->clickLink("Click Me 1!");
|
||||||
|
$this->waitForOffCanvasToOpen();
|
||||||
|
$style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
|
||||||
|
$this->assertTrue(strstr($style, 'width: 555px;') === FALSE, 'Dialog width reset to default.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Check that header is correct.
|
// Check that header is correct.
|
||||||
|
|
|
@ -31,6 +31,7 @@ class OpenOffCanvasDialogCommandTest extends UnitTestCase {
|
||||||
'draggable' => FALSE,
|
'draggable' => FALSE,
|
||||||
'drupalAutoButtons' => FALSE,
|
'drupalAutoButtons' => FALSE,
|
||||||
'buttons' => [],
|
'buttons' => [],
|
||||||
|
'width' => 300,
|
||||||
],
|
],
|
||||||
'effect' => 'fade',
|
'effect' => 'fade',
|
||||||
'speed' => 1000,
|
'speed' => 1000,
|
||||||
|
|
Loading…
Reference in New Issue