Skip to content

Commit

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

* 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 and yogeshbhutkar committed Dec 18, 2024
1 parent 31d1dcb commit 5325a78
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

0 comments on commit 5325a78

Please sign in to comment.