diff --git a/app/components/primer/alpha/action_bar_element.ts b/app/components/primer/alpha/action_bar_element.ts index 0ec18a9af4..97d2fa0d7b 100644 --- a/app/components/primer/alpha/action_bar_element.ts +++ b/app/components/primer/alpha/action_bar_element.ts @@ -86,11 +86,18 @@ class ActionBarElement extends HTMLElement { bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd, focusOutBehavior: 'wrap', focusableElementFilter: element => { - return !element.closest('.ActionBar-item[hidden]') && !element.closest('li.ActionListItem') + return this.#isVisible(element) } }) } + #isVisible(element: HTMLElement): boolean { + // Safari doesn't support `checkVisibility` yet. + if (typeof element.checkVisibility === 'function') return element.checkVisibility() + + return Boolean(element.offsetParent || element.offsetWidth || element.offsetHeight) + } + #itemGap(): number { return parseInt(window.getComputedStyle(this.itemContainer)?.columnGap, 10) || 0 }