Skip to content

Commit 9786f69

Browse files
andreipavel102222Andrei Pavel
andauthored
fix: update bar bellow the tab when text changes (#8311)
Co-authored-by: Andrei Pavel <[email protected]>
1 parent bc0627d commit 9786f69

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/@react-spectrum/s2/src/Tabs.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,24 +213,25 @@ function TabListInner<T extends object>(props: TabListProps<T>) {
213213
style={props.UNSAFE_style}
214214
className={(props.UNSAFE_className || '') + style({position: 'relative'}, getAllowedOverrides())(null, props.styles)}>
215215
{orientation === 'vertical' &&
216-
<TabLine disabledKeys={disabledKeys} isDisabled={isDisabled} selectedTab={selectedTab} orientation={orientation} density={density} />}
216+
<TabLine disabledKeys={disabledKeys} isDisabled={isDisabled} selectedTab={selectedTab} orientation={orientation} tabList={props} density={density} />}
217217
<RACTabList
218218
{...props}
219219
aria-label={ariaLabel}
220220
aria-labelledby={ariaLabelledBy}
221221
ref={tablistRef}
222222
className={renderProps => tablist({...renderProps, labelBehavior, density})} />
223223
{orientation === 'horizontal' &&
224-
<TabLine disabledKeys={disabledKeys} isDisabled={isDisabled} selectedTab={selectedTab} orientation={orientation} density={density} />}
224+
<TabLine disabledKeys={disabledKeys} isDisabled={isDisabled} selectedTab={selectedTab} orientation={orientation} tabList={props} density={density} />}
225225
</div>
226226
);
227227
}
228228

229-
interface TabLineProps {
229+
interface TabLineProps<T extends object> {
230230
disabledKeys: Iterable<Key> | undefined,
231231
isDisabled: boolean | undefined,
232232
selectedTab: HTMLElement | undefined,
233233
orientation?: Orientation,
234+
tabList: TabListProps<T>,
234235
density?: 'compact' | 'regular'
235236
}
236237

@@ -265,12 +266,13 @@ const selectedIndicator = style<{isDisabled: boolean, orientation?: Orientation}
265266
transitionTimingFunction: 'in-out'
266267
});
267268

268-
function TabLine(props: TabLineProps) {
269+
function TabLine<T extends object>(props: TabLineProps<T>) {
269270
let {
270271
disabledKeys,
271272
isDisabled: isTabsDisabled,
272273
selectedTab,
273274
orientation,
275+
tabList,
274276
density
275277
} = props;
276278
let {direction} = useLocale();
@@ -314,7 +316,7 @@ function TabLine(props: TabLineProps) {
314316

315317
useLayoutEffect(() => {
316318
onResize();
317-
}, [onResize, state?.selectedItem?.key, density, direction, orientation]);
319+
}, [onResize, state?.selectedItem?.key, density, direction, orientation, tabList]);
318320

319321
return (
320322
<div style={{...style}} className={selectedIndicator({isDisabled, orientation})} />

0 commit comments

Comments
 (0)