diff --git a/.changeset/gorgeous-turtles-agree.md b/.changeset/gorgeous-turtles-agree.md new file mode 100644 index 0000000000..00bf9e3633 --- /dev/null +++ b/.changeset/gorgeous-turtles-agree.md @@ -0,0 +1,5 @@ +--- +"@primer/view-components": patch +--- + +Fix NVDA menu item counts that are broken by using '
' inside an 'ActionMenu'. diff --git a/app/components/primer/alpha/action_menu/list.rb b/app/components/primer/alpha/action_menu/list.rb index 0749a815e6..c439fe0e8d 100644 --- a/app/components/primer/alpha/action_menu/list.rb +++ b/app/components/primer/alpha/action_menu/list.rb @@ -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 @@ -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