Skip to content

Commit 87daf49

Browse files
t-hamanoDaniGuardiolatyxla
authored andcommitted
Tabs: Prevent accidental overflow in indicator (#61979)
* Tabs: Consider decimal point in indicator style * Update changelog * Naive solution. * Subpixel size and position workaround. * Add comment. * Move CHANGELOG entry to Unreleased section --------- Co-authored-by: t-hamano <[email protected]> Co-authored-by: DaniGuardiola <[email protected]> Co-authored-by: tyxla <[email protected]>
1 parent d0c985a commit 87daf49

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/components/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Add `text-wrap: balance` fallback to all instances of `text-wrap: pretty` for greater cross browser compatibility. ([#62233](https://github.com/WordPress/gutenberg/pull/62233))
88

9+
### Bug Fixes
10+
11+
- `Tabs`: Prevent accidental overflow in indicator ([#61979](https://github.com/WordPress/gutenberg/pull/61979)).
12+
913
## 28.0.0 (2024-05-31)
1014

1115
### Breaking Changes

packages/components/src/tabs/tablist.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ function useTrackElementOffset(
5353

5454
function updateIndicator( element: HTMLElement ) {
5555
setIndicatorPosition( {
56-
left: element.offsetLeft,
57-
top: element.offsetTop,
58-
width: element.offsetWidth,
59-
height: element.offsetHeight,
56+
// Workaround to prevent unwanted scrollbars, see:
57+
// https://github.com/WordPress/gutenberg/pull/61979
58+
left: Math.max( element.offsetLeft - 1, 0 ),
59+
top: Math.max( element.offsetTop - 1, 0 ),
60+
width: parseFloat( getComputedStyle( element ).width ),
61+
height: parseFloat( getComputedStyle( element ).height ),
6062
} );
6163
updateCallbackRef.current?.();
6264
}

0 commit comments

Comments
 (0)