Skip to content

Commit 11aa0e9

Browse files
authored
fix: Fix NVDA menu item counts that are broken by <form> (primer#2822)
1 parent a28b0b8 commit 11aa0e9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/gorgeous-turtles-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/view-components": patch
3+
---
4+
5+
Fix NVDA menu item counts that are broken by using '<form>' inside an 'ActionMenu'.

app/components/primer/alpha/action_menu/list.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def add_item(item, to:)
8989
def organize_arguments(data: {}, **system_arguments)
9090
content_arguments = system_arguments.delete(:content_arguments) || {}
9191

92+
# When a form is inside a menu, suppress form semantics.
93+
# Otherwise, NVDA will miscount menu items.
94+
form_arguments = system_arguments.delete(:form_arguments) || {}
95+
form_arguments[:html] = form_arguments[:html] || {}
96+
form_arguments[:html][:role] = :none
97+
9298
if system_arguments[:tag] && ITEM_TAG_OPTIONS.include?(system_arguments[:tag])
9399
content_arguments[:tag] = system_arguments[:tag]
94100
end
@@ -115,7 +121,7 @@ def organize_arguments(data: {}, **system_arguments)
115121
)
116122
end
117123

118-
{ data: data, **system_arguments, content_arguments: content_arguments }
124+
{ data: data, **system_arguments, content_arguments: content_arguments, form_arguments: form_arguments }
119125
end
120126
end
121127
end

0 commit comments

Comments
 (0)