Skip to content

Commit

Permalink
fix(gropdown-content.templ): id and aria-labelledby
Browse files Browse the repository at this point in the history
  • Loading branch information
indaco committed May 7, 2024
1 parent 027d65e commit c6f1348
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 33 deletions.
2 changes: 0 additions & 2 deletions gropdown-content.templ
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package gropdown

templ Content() {
<ul
id={ menuId("dropdown.Button.Label") }
role="menu"
class="gdd_content"
aria-labelledby={ buttonId("dropdown.Button.Label") }
data-state="close"
>
{ children... }
Expand Down
28 changes: 1 addition & 27 deletions gropdown-content_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions gropdown-js.templ
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ script GropdownJS(configMap *ConfigMap) {

const dropdownBtn = node.querySelector(".gdd_button")
if (dropdownBtn != null && options?.enabled) {
const dropdownBtnLabel = dropdownBtn.getAttribute("aria-label").toLowerCase()
const menuNode = node.querySelector('[role="menu"]')
menuNode.setAttribute("id", `dropdown-menu-${dropdownBtnLabel}`)
menuNode.setAttribute("aria-labelledby", `dropdown-button-${dropdownBtnLabel}`)

initialize()
node.addEventListener('click', onButtonClick)
node.addEventListener('keydown', onButtonKeydown)
Expand Down
13 changes: 9 additions & 4 deletions gropdown-js_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6f1348

Please sign in to comment.