trait LayoutBuilderSortTrait

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait
  2. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait

LayoutBuilderSortTrait, provides callback for simulated layout change.

Hierarchy

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php, line 10

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript
View source
trait LayoutBuilderSortTrait {
    use SortableTestTrait;
    
    /**
     * {@inheritdoc}
     */
    protected function sortableUpdate($item, $from, $to = NULL) {
        // If container does not change, $from and $to are equal.
        $to = $to ?: $from;
        $script = <<<JS
(function (src, from, to) {
  var sourceElement = document.querySelector(src);
  var fromElement = document.querySelector(from);
  var toElement = document.querySelector(to);

  Drupal.layoutBuilderBlockUpdate(sourceElement, fromElement, toElement)

})('{<span class="php-variable">$item</span>}', '{<span class="php-variable">$from</span>}', '{<span class="php-variable">$to</span>}')

JS;
        $options = [
            'script' => $script,
            'args' => [],
        ];
        $this->getSession()
            ->getDriver()
            ->getWebDriverSession()
            ->execute($options);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
LayoutBuilderSortTrait::sortableUpdate protected function Define to provide any necessary callback following layout change. Overrides SortableTestTrait::sortableUpdate
SortableTestTrait::sortableAfter protected function Simulates a drag moving an element after its sibling in the same container.
SortableTestTrait::sortableTo protected function Simulates a drag on an element from one container to another.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.