"use client" /** * ScrollRegion — keyboard-accessible overflow container. * * Satisfies axe `scrollable-region-focusable` (Safari keyboard scroll parity) * **only while content overflows**. Non-overflowing regions stay out of the * Tab order so short breadcrumbs / fitting tables do not take a full-width * focus stop before their real controls. * * Use for any clipped `overflow-*` region that is not already a DS primitive * (`HorizontalScrollRegion`, `ScrollArea`, `Table`, `CardScrollRegion`). */ import * as React from "react" import { useScrollOverflow } from "../../hooks/use-scroll-overflow" import { composeRefs } from "../../lib/compose-refs" import { cn } from "../../lib/utils" export type ScrollRegionProps = React.ComponentProps<"div"> & { /** Accessible name for the scroll viewport. */ label: string } export const ScrollRegion = React.forwardRef( function ScrollRegion({ label, className, children, tabIndex, ...props }, ref) { const { ref: localRef, overflowing } = useScrollOverflow() const resolvedTabIndex = tabIndex !== undefined ? tabIndex : overflowing ? 0 : undefined return (
{children}
) }, ) ScrollRegion.displayName = "ScrollRegion"