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

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

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