Skip to content

Commit

Permalink
Fix: Add soft deperecation notice for the ButtonGroup component (#65429)
Browse files Browse the repository at this point in the history
* Add deperecation notice for the ButtonGroup component

* Address the feedbacks for deprecation for ButtonGroupControl

* Add the changelog deprecation message.

* Update the changelog comment

Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
  • Loading branch information
4 people authored Dec 17, 2024
1 parent be2238f commit 028f72d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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
9 changes: 8 additions & 1 deletion packages/components/src/button-group/stories/index.story.tsx
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';

/**
* 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

1 comment on commit 028f72d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 028f72d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12381262063
📝 Reported issues:

Please sign in to comment.