diff --git a/core/modules/outside_in/js/outside_in.es6.js b/core/modules/outside_in/js/outside_in.es6.js index f36bb835f2..d03aecf236 100644 --- a/core/modules/outside_in/js/outside_in.es6.js +++ b/core/modules/outside_in/js/outside_in.es6.js @@ -152,6 +152,30 @@ $editables .not(contextualItemsSelector) .on('click.outsidein', (e) => { + const $offCanvasToggleLink = $(e.currentTarget).find(blockConfigureSelector); + if ($offCanvasToggleLink.once('offCanvasFullscreen').length + && $offCanvasToggleLink.attr('data-dialog-renderer') === 'off_canvas') { + // Find all Ajax instances that use the 'off_canvas' renderer. + Drupal.ajax.instances + // Loop through all Ajax instances that use the 'off_canvas' renderer to + // set active editable ID. + .forEach((instance) => { + if (instance && instance.element !== $offCanvasToggleLink.get(0)) { + return; + } + // If there is an element and the renderer is 'off_canvas' then we want + // to add our changes. + if ((instance.progress && instance.progress.type && instance.progress.type !== 'fullscreen')) { + // Check to make sure existing dialogOptions aren't overridden. + if (!('dialogOptions' in instance.options.data)) { + instance.options.data.dialogOptions = {}; + } + instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id'); + instance.progress = { type: 'fullscreen' }; + } + }); + } + // Contextual links are allowed to function in Edit mode. if ($(e.target).closest('.contextual').length || !localStorage.getItem('Drupal.contextualToolbar.isViewing')) { return; @@ -202,21 +226,6 @@ Drupal.behaviors.toggleEditMode = { attach() { $(toggleEditSelector).once('outsidein').on('click.outsidein', toggleEditMode); - // Find all Ajax instances that use the 'off_canvas' renderer. - Drupal.ajax.instances - // If there is an element and the renderer is 'off_canvas' then we want - // to add our changes. - .filter(instance => $(instance.element).attr('data-dialog-renderer') === 'off_canvas') - // Loop through all Ajax instances that use the 'off_canvas' renderer to - // set active editable ID. - .forEach((instance) => { - // Check to make sure existing dialogOptions aren't overridden. - if (!('dialogOptions' in instance.options.data)) { - instance.options.data.dialogOptions = {}; - } - instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id'); - instance.progress = { type: 'fullscreen' }; - }); }, }; diff --git a/core/modules/outside_in/js/outside_in.js b/core/modules/outside_in/js/outside_in.js index dc949c7bd7..8afa6aab38 100644 --- a/core/modules/outside_in/js/outside_in.js +++ b/core/modules/outside_in/js/outside_in.js @@ -86,6 +86,23 @@ document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true); $editables.not(contextualItemsSelector).on('click.outsidein', function (e) { + var $offCanvasToggleLink = $(e.currentTarget).find(blockConfigureSelector); + if ($offCanvasToggleLink.once('offCanvasFullscreen').length && $offCanvasToggleLink.attr('data-dialog-renderer') === 'off_canvas') { + Drupal.ajax.instances.forEach(function (instance) { + if (instance && instance.element !== $offCanvasToggleLink.get(0)) { + return; + } + + if (instance.progress && instance.progress.type && instance.progress.type !== 'fullscreen') { + if (!('dialogOptions' in instance.options.data)) { + instance.options.data.dialogOptions = {}; + } + instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id'); + instance.progress = { type: 'fullscreen' }; + } + }); + } + if ($(e.target).closest('.contextual').length || !localStorage.getItem('Drupal.contextualToolbar.isViewing')) { return; } @@ -122,16 +139,6 @@ Drupal.behaviors.toggleEditMode = { attach: function attach() { $(toggleEditSelector).once('outsidein').on('click.outsidein', toggleEditMode); - - Drupal.ajax.instances.filter(function (instance) { - return $(instance.element).attr('data-dialog-renderer') === 'off_canvas'; - }).forEach(function (instance) { - if (!('dialogOptions' in instance.options.data)) { - instance.options.data.dialogOptions = {}; - } - instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id'); - instance.progress = { type: 'fullscreen' }; - }); } };