Skip to content

Commit 4fa65eb

Browse files
committed
fix: clear overflow when items fit without More button reserve
1 parent ac120ed commit 4fa65eb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/react/src/UnderlineNav/UnderlineNav.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ function handleOverflow(
245245
iconPhaseRef.current = 'normal'
246246
}
247247

248+
// IO uses a negative rootMargin to reserve space for the More button.
249+
// On a grow transition, items might appear clipped within the shrunken
250+
// detection zone but actually fit in the full container width (since
251+
// removing overflow also removes the More button). Check scrollWidth
252+
// to avoid a false-positive overflow.
253+
if (list.scrollWidth <= list.clientWidth) {
254+
setOverflowStartIndex(-1)
255+
return
256+
}
257+
248258
// Accessibility: never show only 1 item in the overflow menu.
249259
let adjustedIndex = firstOverflow
250260
const overflowCount = itemCount - firstOverflow

0 commit comments

Comments
 (0)