Close FAQ if clicking when already open

This commit is contained in:
Pk11 2021-06-17 23:13:56 -05:00
parent f66f7ef948
commit f9c6125579

View File

@ -1,7 +1,16 @@
function setFaq(tab) { function setFaq(tab) {
let url = new URL(window.location); if(document.getElementById(`faq-${tab}`).checked) {
url.searchParams.set("faq", tab); let url = new URL(window.location);
history.pushState({}, "", url); 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 // Try get FAQ from URL