From 34b1d0e9d747d6dfcf3606b13fcb90d7ac8f9d06 Mon Sep 17 00:00:00 2001 From: Neil Dewhurst Date: Thu, 22 Aug 2024 14:14:05 +0100 Subject: [PATCH] Fix version selector bugs (#255) Recent updates in the version selector, and previous changes that were specific to the cheat sheet, meant the version of the cheat that is being displayed was excluded from the version selector. This PR fixes that and a bug in the code for defining the default product to display. --- src/js/50-cheat-sheet-toggle.js | 8 +++++++- src/partials/nav-selectors.hbs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/js/50-cheat-sheet-toggle.js b/src/js/50-cheat-sheet-toggle.js index ff0af990..eb72a47c 100644 --- a/src/js/50-cheat-sheet-toggle.js +++ b/src/js/50-cheat-sheet-toggle.js @@ -26,8 +26,14 @@ const prodMatrix = { // get the default product from optionMap const defaultProdArray = optionMap.find((prod) => prod.default === 'true') -const defaultProd = defaultProdArray ? defaultProdArray.value : optionMap[0].value +// display for 'all' products unless a differnt value is specified via attributes in source +let defaultProd +if (defaultProdArray && optionMap) { + defaultProd = defaultProdArray ? defaultProdArray.value : optionMap[0].value +} else { + defaultProd = 'all' +} const defaultClasses = ['exampleblock', 'sect2', 'sect1'] document.addEventListener('DOMContentLoaded', function () { diff --git a/src/partials/nav-selectors.hbs b/src/partials/nav-selectors.hbs index 65c9e705..a63a6301 100644 --- a/src/partials/nav-selectors.hbs +++ b/src/partials/nav-selectors.hbs @@ -17,7 +17,7 @@