[object Object]

← back to Raffiawalls

sort + density pre-load hydration — state.sort now hydrated from localStorage before first loadGridPage()

d6805476058129548faf85ebf96140d483aca79c · 2026-05-25 21:25:51 -0700 · Steve Abrams

Files touched

Diff

commit d6805476058129548faf85ebf96140d483aca79c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon May 25 21:25:51 2026 -0700

    sort + density pre-load hydration — state.sort now hydrated from localStorage before first loadGridPage()
---
 public/index.html | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/public/index.html b/public/index.html
index 12227d4..cc6ced3 100644
--- a/public/index.html
+++ b/public/index.html
@@ -574,12 +574,14 @@ const state = { q:'', facet:'all', page:1, pages:1, total:0, loading:false, exha
 // Touch device = no hover. Drives tap-to-reveal card behavior.
 const TOUCH = window.matchMedia('(hover: none)').matches;
 const HOSTKEY = location.hostname.replace(/\./g, '_');
-// DW STANDARD: hydrate saved view BEFORE the first grid load.
+// DW STANDARD: hydrate saved view + sort BEFORE the first grid load.
 (function(){
   try {
     const savedView = localStorage.getItem(HOSTKEY + '_view');
     if (savedView === 'list' || savedView === 'grid') state.view = savedView;
     document.documentElement.dataset.view = state.view;
+    const savedSort = localStorage.getItem(HOSTKEY + '_sort');
+    if (savedSort) state.sort = savedSort;
   } catch(e){}
 })();
 const LABELS = {"all":"All"};
@@ -1092,13 +1094,15 @@ loadGridPage();
 
 
 // DW STANDARD sort-select wire-up (added by fleet patcher)
+// NOTE: state.sort is hydrated from localStorage in the pre-load block above;
+// here we just sync the dropdown UI to that value + wire the change handler.
 (function(){
   const sortSel = document.getElementById('sortSelect');
   if (!sortSel) return;
   const KEY = location.hostname.replace(/\./g, '_') + '_sort';
-  const saved = localStorage.getItem(KEY);
-  if (saved) { try { sortSel.value = saved; } catch(e){} }
-  if (typeof state !== 'undefined') state.sort = sortSel.value;
+  if (typeof state !== 'undefined' && state.sort) {
+    try { sortSel.value = state.sort; } catch(e){}
+  }
   sortSel.addEventListener('change', e => {
     const v = e.target.value;
     try { localStorage.setItem(KEY, v); } catch(e){}

← 61f351f retag aesthetic from PG: 41 rows updated  ·  back to Raffiawalls  ·  /api/facets total now reflects FILTERED list (honors q + aes 066aa0d →