summaryrefslogtreecommitdiff
path: root/web/source/frontend/index.js
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-04-14 15:12:21 +0200
committerLibravatar GitHub <noreply@github.com>2025-04-14 15:12:21 +0200
commitb510f3c539fb6c71ffba6f32974193d6fb035165 (patch)
tree806366700ac126e306d6605f153437ba3c930a15 /web/source/frontend/index.js
parent[bugfix] websocket header token not always returned (#4009) (diff)
downloadgotosocial-b510f3c539fb6c71ffba6f32974193d6fb035165.tar.xz
[bugfix/frontend] Fix photoswipe layout issues, keyboard shortcuts (#4010)
* fix photoswipe layout issues (chrome) * aaaaaaaaaaaaaa * wwwwwwwwwwww
Diffstat (limited to 'web/source/frontend/index.js')
-rw-r--r--web/source/frontend/index.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js
index 6d4b1470d..b9de769bd 100644
--- a/web/source/frontend/index.js
+++ b/web/source/frontend/index.js
@@ -179,19 +179,24 @@ dynamicSpoiler("text-spoiler", (details) => {
const summary = details.children[0];
const button = details.querySelector(".button");
- // Use button inside summary to
- // toggle post body visibility.
+ // Use button *instead of summary*
+ // to toggle post visibility.
+ summary.tabIndex = "-1";
button.tabIndex = "0";
button.setAttribute("aria-role", "button");
- button.onclick = () => {
- details.click();
+ button.onclick = (e) => {
+ e.preventDefault();
+ return details.hasAttribute("open")
+ ? details.removeAttribute("open")
+ : details.setAttribute("open", "");
};
// Let enter also trigger the button
// (for those using keyboard to navigate).
button.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
- summary.click();
+ e.preventDefault();
+ button.click();
}
});
@@ -215,15 +220,19 @@ dynamicSpoiler("media-spoiler", (details) => {
summary.tabIndex = "-1";
button.tabIndex = "0";
button.setAttribute("aria-role", "button");
- button.onclick = () => {
- details.click();
+ button.onclick = (e) => {
+ e.preventDefault();
+ return details.hasAttribute("open")
+ ? details.removeAttribute("open")
+ : details.setAttribute("open", "");
};
// Let enter also trigger the button
// (for those using keyboard to navigate).
button.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
- summary.click();
+ e.preventDefault();
+ button.click();
}
});