Skip to content

Instantly share code, notes, and snippets.

@superbiche
Created September 29, 2021 21:50
Show Gist options
  • Save superbiche/96ea137e460c564fdac9a5bff27523c1 to your computer and use it in GitHub Desktop.
Save superbiche/96ea137e460c564fdac9a5bff27523c1 to your computer and use it in GitHub Desktop.
diff --git a/block_breakpoint.module b/block_breakpoint.module
index b3d0f4b..1a6d711 100644
--- a/block_breakpoint.module
+++ b/block_breakpoint.module
@@ -51,7 +51,7 @@ function block_breakpoint_form_layout_builder_configure_block_alter(&$form, Form
*/
function block_breakpoint_preprocess_layout(&$variables) {
$layout = $variables['layout'] ?? NULL;
- if ($regions = $layout->getRegionNames()) {
+ if (is_object($layout) && is_callable('getRegionNames', $layout) && $regions = $layout->getRegionNames()) {
foreach ($regions as $region_name) {
if (isset($variables['content'][$region_name])) {
_block_breakpoint_layout_builder_add($variables, $region_name);
diff --git a/src/BlockBreakpointManager.php b/src/BlockBreakpointManager.php
index 2326aa6..06b1d5a 100644
--- a/src/BlockBreakpointManager.php
+++ b/src/BlockBreakpointManager.php
@@ -43,6 +43,8 @@ class BlockBreakpointManager {
*/
protected $breakpointManager;
+ static $hasAddedScripts = false;
+
/**
* Constructs a new BlockBreakpointManager object.
*
@@ -274,7 +276,9 @@ class BlockBreakpointManager {
$variables['attributes']['data-block-breakpoint-hide'] = $block->getThirdPartySetting('block_breakpoint', 'hide');
// Add inline script to remove blocks while they are processed in the
// browser.
+ // FIXME this breaks the branding block. Try it.
$variables['content'] = [$variables['content']];
+ // TODO only add first time.
$variables['content'][] = [
'#theme' => 'block_breakpoint_inline_match',
'#weight' => -50,
@@ -302,6 +306,7 @@ class BlockBreakpointManager {
// Add inline script to remove blocks while they are processed in the
// browser.
$component['content'] = [$component['content']];
+ // TODO only add first time.
$component['content'][] = [
'#theme' => 'block_breakpoint_inline_match',
'#weight' => -50,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment