[object Object]

← back to Designer Wallcoverings

dw-boost-overrides: re-mount density slider+filter toggle+ptype bar into visible Boost toolbar when anchored variant is display:none (FIX 2)

0f8a6b799127a1cc5cadcdbd2a19ae0b5408e550 · 2026-06-27 17:00:02 -0700 · Steve Abrams

Files touched

Diff

commit 0f8a6b799127a1cc5cadcdbd2a19ae0b5408e550
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sat Jun 27 17:00:02 2026 -0700

    dw-boost-overrides: re-mount density slider+filter toggle+ptype bar into visible Boost toolbar when anchored variant is display:none (FIX 2)
---
 .../theme-files/snippets/dw-boost-overrides.liquid | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/shopify/theme-files/snippets/dw-boost-overrides.liquid b/shopify/theme-files/snippets/dw-boost-overrides.liquid
index cf7c1494..d823fed8 100644
--- a/shopify/theme-files/snippets/dw-boost-overrides.liquid
+++ b/shopify/theme-files/snippets/dw-boost-overrides.liquid
@@ -419,6 +419,47 @@ body.dw-filters-collapsed .boost-sd__product-list[class*="grid--"]{grid-template
     toolbarRow.insertBefore(sliderWrap, toolbar);
     toolbarRow.insertBefore(ptypeBar, toolbar);
 
+    /* === VISIBLE-TOOLBAR RE-MOUNT (DW 2026-06-27, vp-dw-commerce) ===
+       Boost renders SEVERAL toolbar variants and hides all but one via
+       display:none (live = .boost-sd__toolbar--3_1 is hidden). The product-count
+       item we anchor to (toolbar.parentElement) can therefore be inside a HIDDEN
+       variant, so the density slider + filter toggle + product-type bar never
+       reach real users — only the color-sort pill survives because IT already
+       has a fallback into the visible .boost-sd__toolbar-inner.
+
+       Fix (mirrors the proven color-sort mount EXACTLY): only when our anchored
+       controls land in a HIDDEN toolbar, MOVE them into the same visible
+       .boost-sd__toolbar-inner / .boost-sd__toolbar-content container the color
+       pill uses. When --3_1 (or whatever variant) IS visible, this no-ops, so the
+       existing multi-variant robustness is preserved — we never regress the
+       already-working case, we only rescue the hidden one. Deferred so Boost has
+       finished sizing the variants (offsetParent is reliable post-layout). */
+    function isShownEl(el){ return !!(el && el.offsetParent !== null); }
+    (function remountIfHidden(tries){
+      tries = tries || 0;
+      /* If our slider is already visible to the user, nothing to do. */
+      if (isShownEl(sliderWrap)) return;
+      /* Find the toolbar container Boost is actually displaying (same selector
+         set the color-sort pill resolves against), and make sure it isn't the
+         hidden row our controls are currently in. */
+      var inners = [].slice.call(document.querySelectorAll(
+        '.boost-sd__toolbar-inner, .boost-sd__toolbar-content'));
+      var target = null;
+      for (var i = 0; i < inners.length; i++){
+        if (isShownEl(inners[i]) && !inners[i].contains(sliderWrap)) { target = inners[i]; break; }
+      }
+      if (target){
+        /* Move (not clone) so all wired event listeners + state come along. */
+        target.appendChild(btn);
+        target.appendChild(sliderWrap);
+        target.appendChild(ptypeBar);
+        return;
+      }
+      /* Boost may still be laying out / swapping the visible variant — retry a
+         few times, then give up (worst case = current pre-fix behavior, no regression). */
+      if (tries < 40) setTimeout(function(){ remountIfHidden(tries + 1); }, 250);
+    })(0);
+
     /* Apply grid and watch for Boost overrides */
     applyGrid(defaultCols);
 

← fb378bce auto-save: 2026-06-27T16:40:02 (3 files) — pending-approval/  ·  back to Designer Wallcoverings  ·  dw-boost-overrides: fix re-mount target check — append to vi 4fec4207 →