Skip to content

Commit

Permalink
fix: Fix NVDA menu item counts that are broken by <form> (#2822)
Browse files Browse the repository at this point in the history
  • Loading branch information
smockle committed May 8, 2024
1 parent a28b0b8 commit 11aa0e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-turtles-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Fix NVDA menu item counts that are broken by using '<form>' inside an 'ActionMenu'.
8 changes: 7 additions & 1 deletion app/components/primer/alpha/action_menu/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def add_item(item, to:)
def organize_arguments(data: {}, **system_arguments)
content_arguments = system_arguments.delete(:content_arguments) || {}

# When a form is inside a menu, suppress form semantics.
# Otherwise, NVDA will miscount menu items.
form_arguments = system_arguments.delete(:form_arguments) || {}
form_arguments[:html] = form_arguments[:html] || {}
form_arguments[:html][:role] = :none

if system_arguments[:tag] && ITEM_TAG_OPTIONS.include?(system_arguments[:tag])
content_arguments[:tag] = system_arguments[:tag]
end
Expand All @@ -115,7 +121,7 @@ def organize_arguments(data: {}, **system_arguments)
)
end

{ data: data, **system_arguments, content_arguments: content_arguments }
{ data: data, **system_arguments, content_arguments: content_arguments, form_arguments: form_arguments }
end
end
end
Expand Down

0 comments on commit 11aa0e9

Please sign in to comment.