Skip to content

Commit 36a044a

Browse files
authoredAug 6, 2024··
Add aria-haspopup and aria-expanded to invoker (#2989)
1 parent 3bf8fd4 commit 36a044a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed
 

‎.changeset/tall-ladybugs-divide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': patch
3+
---
4+
5+
Add `aria-haspopup` and `aria-expanded` to `SelectPanel` state

‎app/components/primer/alpha/select_panel.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def initialize(
461461

462462
system_arguments[:aria] = merge_aria(
463463
system_arguments,
464-
{ aria: { controls: "#{@panel_id}-dialog" } }
464+
{ aria: { controls: "#{@panel_id}-dialog", "haspopup": "dialog", "expanded": "false" } }
465465
)
466466

467467
Primer::Beta::Button.new(**system_arguments)

‎app/components/primer/alpha/select_panel_element.ts

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const updateWhenVisible = (() => {
5454
})
5555
resizeObserver.observe(el.ownerDocument.documentElement)
5656
el.addEventListener('dialog:close', () => {
57+
el.invokerElement?.setAttribute('aria-expanded', 'false')
5758
anchors.delete(el)
5859
})
5960
el.addEventListener('dialog:open', () => {
@@ -466,6 +467,7 @@ export class SelectPanelElement extends HTMLElement {
466467
if (event.target === this.dialog && event.type === 'close') {
467468
// Remove data-ready so it can be set the next time the panel is opened
468469
this.dialog.removeAttribute('data-ready')
470+
this.invokerElement?.setAttribute('aria-expanded', 'false')
469471

470472
this.dispatchEvent(
471473
new CustomEvent('panelClosed', {
@@ -908,6 +910,7 @@ export class SelectPanelElement extends HTMLElement {
908910
show() {
909911
this.updateAnchorPosition()
910912
this.dialog.showModal()
913+
this.invokerElement?.setAttribute('aria-expanded', 'true')
911914
const event = new CustomEvent('dialog:open', {
912915
detail: {dialog: this.dialog},
913916
})

0 commit comments

Comments
 (0)
Please sign in to comment.