Commit c67c0e30 authored by Cottser's avatar Cottser

Issue #2901205 by tedbow, SKAUGHT: Settings tray leaves dashed outline on followup pages

parent 5583e7d5
......@@ -23,6 +23,14 @@
* @listens event:drupalContextualLinkAdded
*/
$(document).on('drupalContextualLinkAdded', (event, data) => {
// When the first contextual link is added to the page set Edit Mode.
$('body').once('outside_in.edit_mode_init').each(() => {
const editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
}
});
// Bind Ajax behaviors to all items showing the class.
// @todo Fix contextual links to work with use-ajax links in
// https://www.drupal.org/node/2764931.
......@@ -183,23 +191,6 @@
$('.edit-mode-inactive').toggleClass('visually-hidden', editMode);
}
/**
* Attaches contextual's edit toolbar tab behavior.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches contextual toolbar behavior on a contextualToolbar-init event.
*/
Drupal.behaviors.outsideInEdit = {
attach() {
const editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
}
},
};
/**
* Toggle the js-outside-edit-mode class on items that we want to disable while in edit mode.
*
......
......@@ -13,6 +13,13 @@
var quickEditItemSelector = '[data-quickedit-entity-id]';
$(document).on('drupalContextualLinkAdded', function (event, data) {
$('body').once('outside_in.edit_mode_init').each(function () {
var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
}
});
Drupal.attachBehaviors(data.$el[0]);
data.$el.find(blockConfigureSelector).on('click.outsidein', function () {
......@@ -112,15 +119,6 @@
$('.edit-mode-inactive').toggleClass('visually-hidden', editMode);
}
Drupal.behaviors.outsideInEdit = {
attach: function attach() {
var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
}
}
};
Drupal.behaviors.toggleEditMode = {
attach: function attach() {
$(toggleEditSelector).once('outsidein').on('click.outsidein', toggleEditMode);
......
......@@ -238,6 +238,9 @@ protected function openBlockForm($block_selector, $contextual_link_container = '
// 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);
// When page first loads Edit Mode is not triggered until first contextual
// link is added.
$this->assertElementVisibleAfterWait('css', '.dialog-off-canvas__main-canvas.js-outside-in-edit-mode');
// Ensure that all other Ajax activity is completed.
$this->assertSession()->assertWaitOnAjaxRequest();
$this->click($block_selector);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment