From f9c6125579b3eae4b2f0a95cf6ac055671dd1f3b Mon Sep 17 00:00:00 2001 From: Pk11 Date: Thu, 17 Jun 2021 23:13:56 -0500 Subject: [PATCH] Close FAQ if clicking when already open --- assets/js/faq.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/js/faq.js b/assets/js/faq.js index de78275d..dd42f8cf 100644 --- a/assets/js/faq.js +++ b/assets/js/faq.js @@ -1,7 +1,16 @@ function setFaq(tab) { - let url = new URL(window.location); - url.searchParams.set("faq", tab); - history.pushState({}, "", url); + if(document.getElementById(`faq-${tab}`).checked) { + let url = new URL(window.location); + url.searchParams.delete("faq"); + history.pushState({}, "", url); + // TODO: This is dumb, try do it better + window.setTimeout(() => document.getElementById(`faq-${tab}`).checked = false, 100); + } else { + let url = new URL(window.location); + url.searchParams.set("faq", tab); + history.pushState({}, "", url); + } + } // Try get FAQ from URL