-
- {/* biome-ignore lint/a11y/useKeyWithClickEvents:
*/}
-
-
{children}
+ return (
+
+
+ {/* biome-ignore lint/a11y/useKeyWithClickEvents:
*/}
+
-
- );
-}
+ );
+ },
+);
diff --git a/packages/lab/src/tabs-next/TabstripNext.tsx b/packages/lab/src/tabs-next/TabstripNext.tsx
index fd2eb056768..011d5787da1 100644
--- a/packages/lab/src/tabs-next/TabstripNext.tsx
+++ b/packages/lab/src/tabs-next/TabstripNext.tsx
@@ -62,15 +62,22 @@ export const TabstripNext = forwardRef(
const tabstripRef = useRef(null);
const handleRef = useForkRef(tabstripRef, ref);
- const { registerItem, setSelected, selected, handleKeyDown } = useTabstrip({
- defaultSelected: defaultValue,
- selected: value,
- });
+ const addButtonRef = useRef(null);
+ const overflowButtonRef = useRef(null);
+
+ const { registerItem, setSelected, selected, handleKeyDown, items } =
+ useTabstrip({
+ defaultSelected: defaultValue,
+ selected: value,
+ });
- const [visible, hidden] = useOverflow({
+ const [visible, hidden, isMeasuring] = useOverflow({
container: tabstripRef,
+ tabs: items,
children,
selected,
+ addButton: addButtonRef,
+ overflowButton: overflowButtonRef,
});
const [focusInside, setFocusInside] = useState(false);
@@ -119,11 +126,21 @@ export const TabstripNext = forwardRef(
>
{visible}
{onAdd && (
-
);
diff --git a/packages/lab/src/tabs-next/useOverflow.tsx b/packages/lab/src/tabs-next/useOverflow.tsx
index 7bdd97ff348..c14afddbe0f 100644
--- a/packages/lab/src/tabs-next/useOverflow.tsx
+++ b/packages/lab/src/tabs-next/useOverflow.tsx
@@ -1,84 +1,183 @@
-import { useIsomorphicLayoutEffect } from "@salt-ds/core";
+import {
+ useIsomorphicLayoutEffect,
+ useResizeObserver,
+ useValueEffect,
+} from "@salt-ds/core";
import { useWindow } from "@salt-ds/window";
import {
Children,
type ReactNode,
type RefObject,
+ useCallback,
useMemo,
- useState,
} from "react";
+import type { Item } from "./useTabstrip";
-export function useOverflow({
- container,
- selected,
- children,
-}: {
+interface UseOverflowProps {
container: RefObject