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

8.5.x
Scott Reeves 2017-08-11 11:38:04 -04:00
parent 5583e7d583
commit c67c0e302c
3 changed files with 18 additions and 26 deletions

View File

@ -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.
*

View File

@ -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);

View File

@ -238,6 +238,9 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
// 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);