diff --git a/core/modules/outside_in/src/OffCanvasFormDialogTrait.php b/core/modules/outside_in/src/OffCanvasFormDialogTrait.php
index e265a8cb1c..af5beece23 100644
--- a/core/modules/outside_in/src/OffCanvasFormDialogTrait.php
+++ b/core/modules/outside_in/src/OffCanvasFormDialogTrait.php
@@ -74,8 +74,7 @@ protected function buildFormDialog(array &$form, FormStateInterface $form_state)
if ($ajax_callback_added) {
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
- $form['#prefix'] = '
';
- $form['#suffix'] = '
';
+ $form['#attributes']['id'] = 'off-canvas-form';
}
}
@@ -94,7 +93,6 @@ protected function buildFormDialog(array &$form, FormStateInterface $form_state)
public function submitFormDialog(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
if ($form_state->hasAnyErrors()) {
- unset($form['#prefix'], $form['#suffix']);
$form['status_messages'] = [
'#type' => 'status_messages',
'#weight' => -1000,
@@ -169,6 +167,9 @@ protected function getDestinationUrl() {
/**
* Get the redirect destination path if specified in request.
*
+ * \Drupal\Core\Routing\RedirectDestination::get() cannot be used directly
+ * because it will use if 'destination' is not in the query string.
+ *
* @return string|null
* The redirect path or NULL if it is not specified.
*/
diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php
index ff5ba1f29b..f9a5045889 100644
--- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php
+++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php
@@ -108,9 +108,6 @@ public function testBlocks($block_plugin, $new_page_text, $element_selector, $la
// Make sure the changes are present.
$new_page_text_locator = "$block_selector $label_selector:contains($new_page_text)";
$this->assertElementVisibleAfterWait('css', $new_page_text_locator);
- // After the new page text is on the page wait to make sure all Ajax
- // request are completed on the new page.
- $web_assert->assertWaitOnAjaxRequest();
}
$this->openBlockForm($block_selector);
@@ -124,7 +121,7 @@ public function testBlocks($block_plugin, $new_page_text, $element_selector, $la
// Open block form by clicking a element inside the block.
// This confirms that default action for links and form elements is
// suppressed.
- $this->openBlockForm("$block_selector {$element_selector}");
+ $this->openBlockForm("$block_selector {$element_selector}", $block_selector);
$web_assert->elementTextContains('css', '.contextual-toolbar-tab button', 'Editing');
$web_assert->elementAttributeContains('css', '.dialog-off-canvas__main-canvas', 'class', 'js-outside-in-edit-mode');
// Simulate press the Escape key.
@@ -209,8 +206,20 @@ protected function assertOffCanvasBlockFormIsValid() {
*
* @param string $block_selector
* A css selector selects the block or an element within it.
+ * @param string $contextual_link_container
+ * The element that contains the contextual links. If none provide the
+ * $block_selector will be used.
*/
- protected function openBlockForm($block_selector) {
+ protected function openBlockForm($block_selector, $contextual_link_container = '') {
+ if (!$contextual_link_container) {
+ $contextual_link_container = $block_selector;
+ }
+ // Ensure that contextual link element is present because this is required
+ // to open the off-canvas dialog in edit mode.
+ $contextual_link = $this->assertSession()->waitForElement('css', "$contextual_link_container .contextual-links a");
+ $this->assertNotEmpty($contextual_link);
+ // Ensure that all other Ajax activity is completed.
+ $this->assertSession()->assertWaitOnAjaxRequest();
$this->waitForToolbarToLoad();
$this->click($block_selector);
$this->waitForOffCanvasToOpen();