Skip to content

Commit 268d0ae

Browse files
authored
fix(Tabs): adjust active position calculation to account for border width (#328)
Signed-off-by: donniean <[email protected]>
1 parent 0d3d150 commit 268d0ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/components/src/Tabs/Tabs.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,17 @@ export function Tabs({
143143
if (_activeKey in refs.current && wrapperRef.current) {
144144
const element = refs.current[_activeKey];
145145
const rect = element.getBoundingClientRect();
146+
147+
const wrapperStyle = window.getComputedStyle(wrapperRef.current);
148+
const borderLeftWidth = parseFloat(wrapperStyle.borderLeftWidth);
149+
146150
setActivePosition({
147151
width: rect.width,
148152
height: rect.height,
149-
translate: rect.x - wrapperRef.current.getBoundingClientRect().x - WRAPPER_PADDING,
153+
translate:
154+
rect.x -
155+
(wrapperRef.current.getBoundingClientRect().x + borderLeftWidth + 1) -
156+
WRAPPER_PADDING,
150157
translateY: rect.y - wrapperRef.current.getBoundingClientRect().y - WRAPPER_PADDING,
151158
});
152159

0 commit comments

Comments
 (0)