Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix visibility check for non-HTMLElements

When SVGElements are checked for visibility, they'll fail the check
since `offsetWidth` and `offsetHeight` aren't present on them. The
`clientWidth` and `clientHeight` properties may not be used as they
refer to the inset size of potentially hidden but scrollable elements.

Instead, we can only rely on the bounding check and add an exception for
hidden inputs.

See: https://github.com/focus-trap/tabbable/blob/b9c50fea90d392a409c8055001567c4b5d0cac54/src/index.js#L143-L161

+2 -2
+2 -2
src/utils/element.ts
··· 9 9 /** Returns whether an element is visible in the context of focusability. */ 10 10 export const isVisible = (node: Element): boolean => 11 11 !!( 12 - (node as HTMLElement).offsetWidth && 13 - (node as HTMLElement).offsetHeight && 12 + (node.tagName !== 'INPUT' || 13 + (node as HTMLInputElement).type !== 'hidden') && 14 14 node.getClientRects().length && 15 15 getComputedStyle(node).visibility !== 'hidden' 16 16 );