always open filters when popping state

This commit is contained in:
Rhiannon Morris 2020-08-16 11:29:56 +02:00
parent a212487613
commit 069a65ab71

View file

@ -80,7 +80,7 @@ function makeFragment() {
} }
} }
function useFragment(firstLoad) { function useFragment() {
let frag = location.hash.replace(/^#/, ''); let frag = location.hash.replace(/^#/, '');
if (frag == 'all') { if (frag == 'all') {
@ -88,7 +88,7 @@ function useFragment(firstLoad) {
} else if (frag) { } else if (frag) {
let set = new Set(frag.split(';')); let set = new Set(frag.split(';'));
allBoxes.forEach(b => b.checked = set.has(b.id)); allBoxes.forEach(b => b.checked = set.has(b.id));
if (firstLoad) document.getElementById('filters-details').open = true; document.getElementById('filters-details').open = true;
} else { } else {
resetForm(); resetForm();
} }
@ -112,9 +112,9 @@ function setup() {
document.getElementById('clear').addEventListener('click', clear); document.getElementById('clear').addEventListener('click', clear);
document.getElementById('reset').addEventListener('click', reset); document.getElementById('reset').addEventListener('click', reset);
window.addEventListener('popstate', () => useFragment(false)); window.addEventListener('popstate', useFragment);
useFragment(true); useFragment();
} }
window.addEventListener('DOMContentLoaded', setup); window.addEventListener('DOMContentLoaded', setup);