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

Fix: Add soft deperecation notice for the ButtonGroup component #65429

Merged
merged 5 commits into from
Dec 17, 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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- `TreeSelect`: Deprecate 36px default size ([#67855](https://github.com/WordPress/gutenberg/pull/67855)).
- `SelectControl`: Deprecate 36px default size ([#66898](https://github.com/WordPress/gutenberg/pull/66898)).
- `InputControl`: Deprecate 36px default size ([#66897](https://github.com/WordPress/gutenberg/pull/66897)).
- Soft deprecate `ButtonGroup` component. Use `ToggleGroupControl` instead ([#65429](https://github.com/WordPress/gutenberg/pull/65429)).

### Bug Fixes

Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/button-group/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ButtonGroup

<div class="callout callout-alert">
This component is deprecated. Use `ToggleGroupControl` instead.
</div>

ButtonGroup can be used to group any related buttons together. To emphasize related buttons, a group should share a common container.

![ButtonGroup component](https://wordpress.org/gutenberg/files/2018/12/s_96EC471FE9C9D91A996770229947AAB54A03351BDE98F444FD3C1BF0CED365EA_1541792995815_ButtonGroup.png)
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/button-group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ForwardedRef } from 'react';
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand All @@ -22,6 +23,11 @@ function UnforwardedButtonGroup(
const { className, ...restProps } = props;
const classes = clsx( 'components-button-group', className );

deprecated( 'wp.components.ButtonGroup', {
since: '6.8',
alternative: 'wp.components.ToggleGroupControl',
} );

return (
<div ref={ ref } role="group" className={ classes } { ...restProps } />
);
Expand All @@ -31,6 +37,8 @@ function UnforwardedButtonGroup(
* ButtonGroup can be used to group any related buttons together. To emphasize
* related buttons, a group should share a common container.
*
* @deprecated Use `ToggleGroupControl` instead.
*
* ```jsx
* import { Button, ButtonGroup } from '@wordpress/components';
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import type { Meta, StoryObj } from '@storybook/react';
import ButtonGroup from '..';
import Button from '../../button';

hbhalodia marked this conversation as resolved.
Show resolved Hide resolved
/**
* ButtonGroup can be used to group any related buttons together.
* To emphasize related buttons, a group should share a common container.
*
* This component is deprecated. Use `ToggleGroupControl` instead.
*/
const meta: Meta< typeof ButtonGroup > = {
title: 'Components/ButtonGroup',
title: 'Components (Deprecated)/ButtonGroup',
id: 'components-buttongroup',
component: ButtonGroup,
argTypes: {
children: { control: false },
Expand Down
Loading