Skip to content

Commit 34b1d0e

Browse files
authored
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.
1 parent c2f23b1 commit 34b1d0e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/js/50-cheat-sheet-toggle.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ const prodMatrix = {
2626

2727
// get the default product from optionMap
2828
const defaultProdArray = optionMap.find((prod) => prod.default === 'true')
29-
const defaultProd = defaultProdArray ? defaultProdArray.value : optionMap[0].value
3029

30+
// display for 'all' products unless a differnt value is specified via attributes in source
31+
let defaultProd
32+
if (defaultProdArray && optionMap) {
33+
defaultProd = defaultProdArray ? defaultProdArray.value : optionMap[0].value
34+
} else {
35+
defaultProd = 'all'
36+
}
3137
const defaultClasses = ['exampleblock', 'sect2', 'sect1']
3238

3339
document.addEventListener('DOMContentLoaded', function () {

src/partials/nav-selectors.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<select data-current="{{@root.page.version}}" class="version-selector dropdown-styles">
1919
{{#each page.versions}}
20-
{{#unless (or this.prerelease (and (eq this.version @root.page.version) (eq @root.page.attributes.theme 'cheat-sheet') ))}}
20+
{{#unless this.prerelease}}
2121
<option
2222
data-version="{{this.displayVersion}}"
2323
value="{{{relativize this.url}}}"

0 commit comments

Comments
 (0)