aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-03-08 14:01:03 -0500
committertdro <tdro@noreply.example.com>2024-03-08 14:01:03 -0500
commit7880038d9577fb0a14a30d2f7fab9f25304d8fd1 (patch)
treeb616c35bd481c6b3906eaf52c6fd541caf4bd44e
parent4e74a82ddfc1ad27d58295e9bae4f8e5ab5bb604 (diff)
downloadcanory-7880038d9577fb0a14a30d2f7fab9f25304d8fd1.tar.gz
canory-7880038d9577fb0a14a30d2f7fab9f25304d8fd1.tar.bz2
canory-7880038d9577fb0a14a30d2f7fab9f25304d8fd1.zip
static/js/forms: Handle child in summary details
-rw-r--r--assets/js/index.js7
-rw-r--r--static/js/forms.ts10
2 files changed, 12 insertions, 5 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index e43c011..e8e307a 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -730,8 +730,11 @@
sessionStorage[details.id] === "false" && details.removeAttribute("open");
sessionStorage[details.id] === "true" && details.setAttribute("open", true);
child.addEventListener("click", function(event) {
- let details = event.target.parentElement;
- sessionStorage[details.id] = !details.open;
+ let child = event.target.nodeName === "SUMMARY" && event.target || event.target.parentElement;
+ let details = child.parentElement;
+ if (details.id && details.nodeName === "DETAILS") {
+ sessionStorage[details.id] = !details.open;
+ }
});
}
}
diff --git a/static/js/forms.ts b/static/js/forms.ts
index e35a4b2..4784b20 100644
--- a/static/js/forms.ts
+++ b/static/js/forms.ts
@@ -58,11 +58,15 @@
if (details.id && details.nodeName === "DETAILS") {
sessionStorage[details.id] === "false" && details.removeAttribute("open");
- sessionStorage[details.id] === "true" && details.setAttribute("open", true);
+ sessionStorage[details.id] === "true" && details.setAttribute("open", true);
child.addEventListener("click", function (event) {
- let details = event.target.parentElement;
- sessionStorage[details.id] = !details.open;
+ let child = (event.target.nodeName === "SUMMARY" && event.target)
+ || event.target.parentElement;
+ let details = child.parentElement;
+ if (details.id && details.nodeName === "DETAILS") {
+ sessionStorage[details.id] = !details.open;
+ }
});
}
}