Skip to content

Commit

Permalink
Tabs: Consider decimal point in indicator style
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed May 25, 2024
1 parent 62b0efd commit 343911c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/components/src/tabs/tablist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ function useTrackElementOffset(
observedElementRef.current = targetElement ?? undefined;

function updateIndicator( element: HTMLElement ) {
const parentElement = element.offsetParent;
if ( ! parentElement ) {
return;
}
const parentRect = parentElement?.getBoundingClientRect();
const rect = element.getBoundingClientRect();
setIndicatorPosition( {
left: element.offsetLeft,
top: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight,
left: rect.left - parentRect.left,
top: rect.top - parentRect.top,
width: rect.width,
height: rect.height,
} );
updateCallbackRef.current?.();
}
Expand Down

0 comments on commit 343911c

Please sign in to comment.