From 240097097c8f991299f51acbf4ce0c89873f0fd0 Mon Sep 17 00:00:00 2001 From: Chesterr <59756-Chester@users.noreply.drupalcode.org> Date: Sat, 27 Jan 2024 09:25:20 +0000 Subject: [PATCH] Issue #3387505: Do not remove the layout-builder-block css class --- css/layout-builder-lock.css | 4 +++- src/LayoutBuilderLock.php | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/css/layout-builder-lock.css b/css/layout-builder-lock.css index a3cb608..b7ebb78 100644 --- a/css/layout-builder-lock.css +++ b/css/layout-builder-lock.css @@ -1,4 +1,6 @@ -.layout-builder-block-locked { +/* Using :not(b) is slightly more specific (0 1 1) than a single class selector but less + specific than 2 class selectors (0 2 0). The element is not likely to be a <b>. */ +.layout-builder-block-locked:not(b) { padding: 1.5em; cursor: default; } diff --git a/src/LayoutBuilderLock.php b/src/LayoutBuilderLock.php index dde898c..6ea9f84 100644 --- a/src/LayoutBuilderLock.php +++ b/src/LayoutBuilderLock.php @@ -216,14 +216,12 @@ class LayoutBuilderLock implements TrustedCallbackInterface { } // If moving is not allowed, remove the default layout builder - // classes on this block and add our own so we can reset the + // js class on this block and add our own so we can reset the // pointer and padding. if (!$allow_moving) { - foreach (['layout-builder-block', 'js-layout-builder-block'] as $class) { - if (isset($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class']) && is_array($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class'])) { - $key = array_search($class, $element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class']); - unset($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class'][$key]); - } + if (isset($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class']) && is_array($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class'])) { + $key = array_search('js-layout-builder-block', $element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class']); + unset($element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class'][$key]); } $element['layout_builder'][$section_number][$name][$region_key][$item_key]['#attributes']['class'][] = 'layout-builder-block-locked'; } -- GitLab