Skip to content

Commit

Permalink
Fix popover open selector for focus group (#2002)
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus authored May 11, 2023
1 parent 52ba250 commit ef2540a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-avocados-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Fix focus groups when using native `popover`
9 changes: 4 additions & 5 deletions app/components/primer/focus_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const menuItemSelector = '[role="menuitem"],[role="menuitemcheckbox"],[role="men

const popoverSelector = (() => {
try {
document.querySelector(':open')
return ':open'
document.querySelector(':popover-open')
return ':popover-open'
} catch {
return '.\\:open'
return '.\\:popover-open'
}
})()

Expand Down Expand Up @@ -121,9 +121,8 @@ export default class FocusGroupElement extends HTMLElement {
el = el.closest(`[popover]:not(${popoverSelector})`)
if (el?.popover === 'auto') {
el.showPopover()
} else {
el = el?.parentElement || null
}
el = el?.parentElement || null
} while (el)
}
focusEl?.focus()
Expand Down

0 comments on commit ef2540a

Please sign in to comment.