From 0a70d6e98109b635d60ffef00dea935c919f4794 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 17 Jan 2021 16:29:46 -0800 Subject: [PATCH] Makes dropdown clickable, and work with screen reader I'm lightly peeved with bulma that it wasn't clear how to make hover menus accessible, but clickable menus are just fine with my anyway. --- bookwyrm/static/js/shared.js | 7 +++++-- .../snippets/components/dropdown.html | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index f4b9a588..edd1653e 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -152,8 +152,11 @@ function handleTabChange(target, parentElement) { } function toggleMenu(e) { - var el = e.target.closest('.pulldown-menu'); - el.setAttribute('aria-expanded', el.getAttribute('aria-expanded') == 'false'); + var el = e.currentTarget; + var expanded = el.getAttribute('aria-expanded') == 'false'; + el.setAttribute('aria-expanded', expanded); + var target = document.getElementById(el.getAttribute('data-controls')); + addRemoveClass(target, 'is-active', expanded); } function ajaxPost(form) { diff --git a/bookwyrm/templates/snippets/components/dropdown.html b/bookwyrm/templates/snippets/components/dropdown.html index 54714dcb..48a808d4 100644 --- a/bookwyrm/templates/snippets/components/dropdown.html +++ b/bookwyrm/templates/snippets/components/dropdown.html @@ -1,13 +1,13 @@ -