diff --git a/core/modules/settings_tray/js/settings_tray.es6.js b/core/modules/settings_tray/js/settings_tray.es6.js index 6487690c7b..db492adb94 100644 --- a/core/modules/settings_tray/js/settings_tray.es6.js +++ b/core/modules/settings_tray/js/settings_tray.es6.js @@ -171,6 +171,16 @@ } instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id'); instance.progress = { type: 'fullscreen' }; + + if (instance.hasOwnProperty('element')) { + // If the ajax element is within a overridden block remove the link. + const disabled = $(instance.element).closest('[data-settings-tray-overridden]'); + if (disabled.length === 1) { + $(instance.element).remove(); + } + } + + }); } diff --git a/core/modules/settings_tray/js/settings_tray.js b/core/modules/settings_tray/js/settings_tray.js index 7a83e156ca..c3bd3a0995 100644 --- a/core/modules/settings_tray/js/settings_tray.js +++ b/core/modules/settings_tray/js/settings_tray.js @@ -102,6 +102,13 @@ } instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id'); instance.progress = { type: 'fullscreen' }; + + if (instance.hasOwnProperty('element')) { + var disabled = $(instance.element).closest('[data-settings-tray-overridden]'); + if (disabled.length === 1) { + $(instance.element).remove(); + } + } }); } diff --git a/core/modules/settings_tray/settings_tray.module b/core/modules/settings_tray/settings_tray.module index 3d525ab310..3f4aca7c80 100644 --- a/core/modules/settings_tray/settings_tray.module +++ b/core/modules/settings_tray/settings_tray.module @@ -115,10 +115,16 @@ function settings_tray_preprocess_block(&$variables) { if (isset($variables['elements']['#contextual_links']['block']['route_parameters']['block'])) { $block_id = $variables['elements']['#contextual_links']['block']['route_parameters']['block']; $block = Block::load($block_id); - if ($access_checker->accessBlockPlugin($block_plugin)->isAllowed() && !_settings_tray_has_block_overrides($block)) { - // Add class and attributes to all blocks to allow Javascript to target. - $variables['attributes']['class'][] = 'settings-tray-editable'; - $variables['attributes']['data-drupal-settingstray'] = 'editable'; + if ($access_checker->accessBlockPlugin($block_plugin)->isAllowed()) { + if (!_settings_tray_has_block_overrides($block)) { + // Add class and attributes to all blocks to allow Javascript to target. + $variables['attributes']['class'][] = 'settings-tray-editable'; + $variables['attributes']['data-drupal-settingstray'] = 'editable'; + } + else { + $variables['attributes']['data-settings-tray-overridden'] = TRUE; + } + } } } @@ -219,15 +225,3 @@ function settings_tray_css_alter(&$css, AttachedAssetsInterface $assets) { $css[$path]['group'] = 200; } } - -/** - * Implements hook_contextual_links_alter(). - */ -function settings_tray_contextual_links_alter(array &$links, $group, array $route_parameters) { - if (isset($links['settings_tray.block_configure']['route_parameters']['block'])) { - $block = Block::load($links['settings_tray.block_configure']['route_parameters']['block']); - if (_settings_tray_has_block_overrides($block)) { - unset($links['settings_tray.block_configure']); - } - } -} diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index 9cf66cc734..b935175eb8 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -627,10 +627,7 @@ public function testOverriddenBlock() { $this->assertEquals('editable', $page->find('css', $block_selector)->getAttribute('data-drupal-settingstray')); // Confirm the label is not overridden. $web_assert->elementContains('css', $block_selector, 'Labely label'); - $this->enableEditMode(); $this->openBlockForm($block_selector); - - } /**