Skip to content

Commit

Permalink
Filter out items that aren't visible
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Oct 18, 2023
1 parent 61c294f commit 23c5ef3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/components/primer/alpha/action_bar_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 23c5ef3

Please sign in to comment.