← back to Dw Domain Fleet
catalog sort: stop remembering the sort, so Back works and the dropdown can't lie (TK-11470)
d0f8c707623951a9990f6e914784187d386a8152 · 2026-09-11 13:11:08 -0700 · Steve Abrams
Steve's call after the red-team surfaced the tradeoff. The reviewed candidate made a
remembered sort re-request from the server via location.replace. That fixed the old
cosmetic lie but cost more than it bought: Back stopped undoing a sort (/catalog ->
?sort=sku -> Back -> /catalog -> instantly redirected back to ?sort=sku, so a shopper
could never reach the unsorted grid), and it double-counted GA4 page_views on
hollywoodwallcovering, the one site of the eight that has GA4 configured.
So /catalog no longer persists sort at all. The dropdown is always exactly what ?sort=
says, which makes the lie structurally impossible rather than merely corrected. Density
is still remembered. Sorting itself is untouched and still fully works.
Also re-syncs the <select> to the URL on pageshow: browsers restore form-control state
across history navigation, so after Back the dropdown still read "SKU A-Z" above a
Newest grid — the same lie by another route. My own new back-undoes-sort check caught
that, and it only goes green once grid AND dropdown both return to Newest.
Same harness, same data: 0 PASS / 38 FAIL on the unfixed baseline, 40 PASS / 0 FAIL here
(adds sort-not-remembered, dropdown-never-lies, no-redirect, back-undoes-sort).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Files touched
Diff
commit d0f8c707623951a9990f6e914784187d386a8152
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Fri Sep 11 13:11:08 2026 -0700
catalog sort: stop remembering the sort, so Back works and the dropdown can't lie (TK-11470)
Steve's call after the red-team surfaced the tradeoff. The reviewed candidate made a
remembered sort re-request from the server via location.replace. That fixed the old
cosmetic lie but cost more than it bought: Back stopped undoing a sort (/catalog ->
?sort=sku -> Back -> /catalog -> instantly redirected back to ?sort=sku, so a shopper
could never reach the unsorted grid), and it double-counted GA4 page_views on
hollywoodwallcovering, the one site of the eight that has GA4 configured.
So /catalog no longer persists sort at all. The dropdown is always exactly what ?sort=
says, which makes the lie structurally impossible rather than merely corrected. Density
is still remembered. Sorting itself is untouched and still fully works.
Also re-syncs the <select> to the URL on pageshow: browsers restore form-control state
across history navigation, so after Back the dropdown still read "SKU A-Z" above a
Newest grid — the same lie by another route. My own new back-undoes-sort check caught
that, and it only goes green once grid AND dropdown both return to Newest.
Same harness, same data: 0 PASS / 38 FAIL on the unfixed baseline, 40 PASS / 0 FAIL here
(adds sort-not-remembered, dropdown-never-lies, no-redirect, back-undoes-sort).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---
shared/render.js | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/shared/render.js b/shared/render.js
index 70ecccc..c4d2f36 100644
--- a/shared/render.js
+++ b/shared/render.js
@@ -765,7 +765,10 @@ ${nsModal(cfg)}
${script(cfg)}
<script>
(function(){
- var dk='${cfg.slug}_density',sk='${cfg.slug}_sort';
+ // Density persists; SORT DELIBERATELY DOES NOT (Steve, TK-11470). The dropdown is always
+ // whatever ?sort= says, so it can never show one ordering above a differently-ordered grid,
+ // Back genuinely undoes a sort, and there is no extra redirect/page_view per visit.
+ var dk='${cfg.slug}_density';
var d=document.getElementById('densSel'),g=document.getElementById('grid');
var ss=document.getElementById('sortSel'),form=document.getElementById('ctlForm');
function read(k){try{return localStorage.getItem(k);}catch(e){return null;}}
@@ -790,15 +793,16 @@ ${script(cfg)}
try{ if(typeof F.requestSubmit==='function'){F.requestSubmit.call(form);return;} }catch(e){}
F.submit.call(form);
}
- ss.addEventListener('change',function(){save(sk,ss.value);send();});
- var saved=read(sk);
- var valid=Array.prototype.some.call(ss.options,function(o){return o.value===saved;});
- if(!params.has('sort') && valid && saved!==ss.value){
- // Request the saved ordering from the server; never merely relabel an unsorted grid.
- params.set('sort',saved);params.delete('page');
- location.replace(location.pathname+'?'+params.toString()+location.hash);
- }
-
+ ss.addEventListener('change',send);
+ // Browsers restore form-control state across history navigation, so after Back the <select>
+ // can still read "SKU A-Z" above a Newest grid — the same lie by another route. Re-sync it to
+ // the URL on every show (pageshow also covers bfcache restores, which fire no other event).
+ window.addEventListener('pageshow',function(){
+ var want=params.get('sort')||'newest';
+ try{ want=new URLSearchParams(location.search).get('sort')||'newest'; }catch(e){}
+ var known=Array.prototype.some.call(ss.options,function(o){return o.value===want;});
+ if(known && ss.value!==want) ss.value=want;
+ });
})();
</script>
</body></html>`;
← 95a4e5a fix(catalog): guard requestSubmit — Safari <16 would have re
·
back to Dw Domain Fleet
·
test(catalog): keep the TK-11470 sort proof harness in-repo b757902 →