Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs and ToggleGroupControl: round indicator size #66426

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `ColorPalette`: prevent overflow of custom color button background ([#66152](https://github.com/WordPress/gutenberg/pull/66152)).
- `RadioGroup`: Fix arrow key navigation in RTL ([#66202](https://github.com/WordPress/gutenberg/pull/66202)).
- `Tabs` and `ToggleGroupControl`: round indicator size ([#66426](https://github.com/WordPress/gutenberg/pull/66426)).

### Enhancements

Expand Down Expand Up @@ -40,8 +41,8 @@

- `Modal`: Modal dialog small improvement for elementShouldBeHidden ([#65941](https://github.com/WordPress/gutenberg/pull/65941)).
- `Tabs`: revamped vertical orientation styles ([#65387](https://github.com/WordPress/gutenberg/pull/65387)).
- `ComboboxControl`: display `No items found` when there are no matches found ([#66142](https://github.com/WordPress/gutenberg/pull/66142))
- `FormTokenField`: display `No items found` when there are no matches found. This occurs when the `__experimentalExpandOnFocus` prop is enabled ([#66142](https://github.com/WordPress/gutenberg/pull/66142))
- `ComboboxControl`: display `No items found` when there are no matches found ([#66142](https://github.com/WordPress/gutenberg/pull/66142))
- `FormTokenField`: display `No items found` when there are no matches found. This occurs when the `__experimentalExpandOnFocus` prop is enabled ([#66142](https://github.com/WordPress/gutenberg/pull/66142))

## 28.9.0 (2024-10-03)

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/tabs/tablist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const TabList = forwardRef<
prefix: 'selected',
dataAttribute: 'indicator-animated',
transitionEndFilter: ( event ) => event.pseudoElement === '::before',
roundRect: true,
} );

// Make sure selected tab is scrolled into view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function UnconnectedToggleGroupControl(
prefix: 'selected',
dataAttribute: 'indicator-animated',
transitionEndFilter: ( event ) => event.pseudoElement === '::before',
roundRect: true,
} );

const cx = useCx();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function useAnimatedOffsetRect(
prefix = 'subelement',
dataAttribute = `${ prefix }-animated`,
transitionEndFilter = () => true,
roundRect = false,
}: {
/**
* The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the
Expand All @@ -72,6 +73,13 @@ export function useAnimatedOffsetRect(
* @default () => true
*/
transitionEndFilter?: ( event: TransitionEvent ) => boolean;
/**
* Whether the `rect` measurements should be rounded down when applied
* to the CSS variables. This can be useful to avoid blurry animations or
* to avoid subpixel rendering issues.
* @default false
*/
roundRect?: boolean;
} = {}
) {
const setProperties = useEvent( () => {
Expand All @@ -80,7 +88,11 @@ export function useAnimatedOffsetRect(
property !== 'element' &&
container?.style.setProperty(
`--${ prefix }-${ property }`,
String( rect[ property ] )
String(
roundRect
? Math.floor( rect[ property ] )
: rect[ property ]
)
)
);
} );
Expand Down
Loading