Skip to content

Commit

Permalink
Fix multi-select behavior when ActionMenus are embedded in dialogs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Oct 18, 2023
1 parent 6d580e3 commit d7eafca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changeset/large-actors-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/view-components': minor
---

Fix multi-select behavior when ActionMenus are embedded in dialogs

<!-- Changed components: Primer::Alpha::ActionMenu -->
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ export class ActionMenuElement extends HTMLElement {
return
}

// Ignore events within dialogs within menus
if ((event.target as Element)?.closest('dialog') || (event.target as Element)?.closest('modal-dialog')) {
return
}

if (event.type === 'focusout') {
if (this.#invokerBeingClicked) return

Expand Down
5 changes: 4 additions & 1 deletion test/system/alpha/action_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_opens_dialog
click_on_invoker_button
click_on_second_item

assert_selector "modal-dialog#my-dialog"
assert_selector "modal-dialog[open]"

# opening the dialog should close the menu
refute_selector "action-menu ul li"
Expand Down Expand Up @@ -523,6 +523,9 @@ def test_deferred_dialog_opens
click_on_fourth_item

assert_selector "modal-dialog[open]"

# menu should close
refute_selector "action-menu ul li"
end

def test_opening_second_menu_closes_first_menu
Expand Down

0 comments on commit d7eafca

Please sign in to comment.