From e1ae3c36d1d2debcae21d0ccd0d05b6deb515838 Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:23:59 +0200 Subject: [PATCH] Attempt to fix error --- .htmltest.yml | 1 + static/js/tutorials.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.htmltest.yml b/.htmltest.yml index b4915f8c6ca..d5c7a7d8203 100644 --- a/.htmltest.yml +++ b/.htmltest.yml @@ -22,6 +22,7 @@ IgnoreURLs: - "slamtec.com" - "softroboticsinc.com" - "universal-robots.com" +- "digikey.com" - "ufactory.cc" IgnoreDirs: - "lib" diff --git a/static/js/tutorials.js b/static/js/tutorials.js index d21a6555511..1981eba0ebe 100644 --- a/static/js/tutorials.js +++ b/static/js/tutorials.js @@ -1,4 +1,3 @@ - document.querySelectorAll('.pill-lang').forEach(e => search.helper.state.facetsRefinements.languages.includes(e.textContent) ? e.classList.add('highlight') : e.classList.remove('highlight')); const { TypesenseInstantSearchAdapter, instantsearch } = window; const observer = lozad(); @@ -187,29 +186,30 @@ search.addWidgets([ search.start(); search.on('render', function() { - if (search.helper.state.facetsRefinements.languages.length) { - document.getElementById("filter-languages").textContent = "Languages (" + search.helper.state.facetsRefinements.languages.length + ")"; + if (search.helper.state.disjunctiveFacetsRefinements.languages && search.helper.state.disjunctiveFacetsRefinements.languages.length) { + document.getElementById("filter-languages").textContent = "Languages (" + search.helper.state.disjunctiveFacetsRefinements.languages.length + ")"; } else { document.getElementById("filter-languages").textContent = "Languages"; } - if (search.helper.state.facetsRefinements.viamcomponents.length) { + if (search.helper.state.facetsRefinements.viamcomponents && search.helper.state.facetsRefinements.viamcomponents.length) { document.getElementById("filter-components").textContent = "Components (" + search.helper.state.facetsRefinements.viamcomponents.length + ")"; } else { document.getElementById("filter-components").textContent = "Components"; } - if (search.helper.state.facetsRefinements.viamservices.length) { + if (search.helper.state.facetsRefinements.viamservices && search.helper.state.facetsRefinements.viamservices.length) { document.getElementById("filter-services").textContent = "Services (" + search.helper.state.facetsRefinements.viamservices.length + ")"; } else { document.getElementById("filter-services").textContent = "Services"; } - if (search.helper.state.disjunctiveFacetsRefinements.level.length) { + if (search.helper.state.disjunctiveFacetsRefinements.level && search.helper.state.disjunctiveFacetsRefinements.level.length) { document.getElementById("filter-level").textContent = "Level (" + search.helper.state.disjunctiveFacetsRefinements.level.length + ")"; } else { document.getElementById("filter-level").textContent = "Level"; } - - document.querySelectorAll('.pill-lang').forEach(e => search.helper.state.facetsRefinements.languages.includes(e.textContent) ? e.classList.add('pill-highlight') : e.classList.remove('pill-highlight')); - document.querySelectorAll('.pill-component').forEach(e => (search.helper.state.facetsRefinements.viamcomponents.includes(e.textContent) || search.helper.state.facetsRefinements.viamservices.includes(e.textContent)) ? e.classList.add('pill-highlight') : e.classList.remove('pill-highlight')); + if (search.helper.state.facetsRefinements && search.helper.state.disjunctiveFacetsRefinements.languages && search.helper.state.facetsRefinements.viamcomponents) { + document.querySelectorAll('.pill-lang').forEach(e => search.helper.state.disjunctiveFacetsRefinements.languages.includes(e.textContent) ? e.classList.add('pill-highlight') : e.classList.remove('pill-highlight')); + document.querySelectorAll('.pill-component').forEach(e => (search.helper.state.facetsRefinements.viamcomponents.includes(e.textContent) || search.helper.state.facetsRefinements.viamservices.includes(e.textContent)) ? e.classList.add('pill-highlight') : e.classList.remove('pill-highlight')); + } observer.observe() });