Skip to content

Commit

Permalink
fix: add role and aria-expanded to dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
ilunglee committed Nov 2, 2021
1 parent dc00596 commit 835d6c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def build(name, options = {})
button_options[:class] = "#{button_options[:class]} dropdown-toggle".squish
options[:class] = "#{options[:class]} dropdown".squish

@button = build_button(name, button_options.merge("data-bs-toggle": "dropdown"))
@button = build_button(
name,
button_options.merge("data-bs-toggle": "dropdown", role: "button", "aria-expanded": "false")
)
@menu = build_menu(menu_options)

super(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def confirm_dialog_config
html =
<<~ERB
<div class="batch_actions_selector dropdown_menu dropdown">
<a class="disabled #{default_css_classes[:btn]} dropdown-toggle dropdown_menu_button" data-bs-toggle="dropdown" href="#">Batch Actions</a>
<a class="disabled #{default_css_classes[:btn]} dropdown-toggle dropdown_menu_button" data-bs-toggle="dropdown" role="button" aria-expanded="false" href="#">Batch Actions</a>
<ul class="dropdown_menu_list dropdown-menu">
<li><a id="batch-action-action_1" class="dropdown-item batch_action" data-action="action_1" data-inputs="null" data-aa-confirm-dialog="#{escape_hash(confirm_dialog_config)}" href="#">Action 1 Selected</a></li>
<li><a id="batch-action-action_2" class="dropdown-item batch_action" data-action="action_2" data-inputs="null" data-aa-confirm-dialog="#{escape_hash(confirm_dialog_config)}" href="#">Action 2 Selected</a></li>
Expand Down
2 changes: 1 addition & 1 deletion test/lib/extensions/views/components/dropdown_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DropDownMenuTest < ActiveAdmin::BaseTestCase
test "#content" do
html =
<<~ERB
<a class="dropdown-toggle dropdown_menu_button" data-bs-toggle="dropdown" href="#">test</a>
<a class="dropdown-toggle dropdown_menu_button" data-bs-toggle="dropdown" role="button" aria-expanded="false" href="#">test</a>
<ul class="dropdown_menu_list dropdown-menu">
<li>
<a class="dropdown-item" href="#">link 1</a>
Expand Down

0 comments on commit 835d6c6

Please sign in to comment.