Skip to content

Commit

Permalink
Tabs: Prevent accidental overflow in indicator (#61979)
Browse files Browse the repository at this point in the history
* 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 <wildworks@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
4 people authored Jun 4, 2024
1 parent 34fa834 commit a9fd33c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- 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))

### Bug Fixes

- `Tabs`: Prevent accidental overflow in indicator ([#61979](https://github.com/WordPress/gutenberg/pull/61979)).

## 28.0.0 (2024-05-31)

### Breaking Changes
Expand Down
10 changes: 6 additions & 4 deletions packages/components/src/tabs/tablist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ function useTrackElementOffset(

function updateIndicator( element: HTMLElement ) {
setIndicatorPosition( {
left: element.offsetLeft,
top: element.offsetTop,
width: element.offsetWidth,
height: element.offsetHeight,
// Workaround to prevent unwanted scrollbars, see:
// https://github.com/WordPress/gutenberg/pull/61979
left: Math.max( element.offsetLeft - 1, 0 ),
top: Math.max( element.offsetTop - 1, 0 ),
width: parseFloat( getComputedStyle( element ).width ),
height: parseFloat( getComputedStyle( element ).height ),
} );
updateCallbackRef.current?.();
}
Expand Down

0 comments on commit a9fd33c

Please sign in to comment.