Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-select behavior when ActionMenus are embedded in dialogs #2293

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading