From 8a6c6fd56d992e4bba071dff7e0511622366b201 Mon Sep 17 00:00:00 2001 From: Marie Birner Date: Mon, 10 Apr 2023 22:46:35 +0200 Subject: [PATCH] [WIP] filter btns session storage --- frontend/main.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/main.ts b/frontend/main.ts index c7c48cd..1e1d7cb 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -21,7 +21,7 @@ function initToggle() { if(filter) { let filterMap = new Map(JSON.parse(filter)); for (let entry of filterMap.entries()) { - if(entry[0] === btn.dataset.action) { + if(entry[0] === btn.dataset.action && entry[1] !== 'true') { filterMap.set(entry[0],'true'); } else { filterMap.set(entry[0],'false'); @@ -30,12 +30,13 @@ function initToggle() { sessionStorage.setItem('tripsFilter', JSON.stringify( Array.from(filterMap.entries()))); } resetFilteredElements(); - console.log(btn.ariaPressed); if(btn.ariaPressed === 'false'){ Array.prototype.forEach.call(btns, (b: HTMLButtonElement) => { b.setAttribute('aria-pressed', 'false'); }); triggerFilterAction(btn.dataset.action); + } else { + btn.setAttribute('aria-pressed', 'false'); } }); });