Skip to content

Commit

Permalink
Components: Remove unnecessary Tooltip component from linked `butto…
Browse files Browse the repository at this point in the history
…n` (WordPress#68498)

* fix: Removed extra tooltips component in button component

* fix: label name

* fix: Removed view component

* doc: Update changelog for unreleased section

* Add heading before new changelog entry

---------

Co-authored-by: im3dabasia <[email protected]>
Co-authored-by: afercia <[email protected]>
Co-authored-by: ciampo <[email protected]>
  • Loading branch information
4 people authored Jan 24, 2025
1 parent 2eaed20 commit d516b23
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/**
* WordPress dependencies
*/
import { Button, Tooltip } from '@wordpress/components';
import { Button } from '@wordpress/components';
import { link, linkOff } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

export default function LinkedButton( { isLinked, ...props } ) {
const label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );

return (
<Tooltip text={ label }>
<Button
{ ...props }
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
aria-label={ label }
/>
</Tooltip>
<Button
{ ...props }
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
label={ label }
/>
);
}
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- `BorderBoxControl`, `BoxControl`: Remove `Tooltip` component from linked button ([#68498](https://github.com/WordPress/gutenberg/pull/68498)).

### Internal

- `BoxControl`: Add runtime check for presets and presetKey ([#68385](https://github.com/WordPress/gutenberg/pull/68385)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import Button from '../../button';
import Tooltip from '../../tooltip';
import { View } from '../../view';
import type { WordPressComponentProps } from '../../context';
import { contextConnect } from '../../context';
import { useBorderBoxControlLinkedButton } from './hook';
Expand All @@ -25,18 +23,15 @@ const BorderBoxControlLinkedButton = (
const label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );

return (
<Tooltip text={ label }>
<View className={ className }>
<Button
{ ...buttonProps }
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
aria-label={ label }
ref={ forwardedRef }
/>
</View>
</Tooltip>
<Button
{ ...buttonProps }
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
label={ label }
ref={ forwardedRef }
className={ className }
/>
);
};

Expand Down
19 changes: 8 additions & 11 deletions packages/components/src/box-control/linked-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import Button from '../button';
import Tooltip from '../tooltip';

export default function LinkedButton( {
isLinked,
Expand All @@ -17,15 +16,13 @@ export default function LinkedButton( {
const label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );

return (
<Tooltip text={ label }>
<Button
{ ...props }
className="component-box-control__linked-button"
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
aria-label={ label }
/>
</Tooltip>
<Button
{ ...props }
className="component-box-control__linked-button"
size="small"
icon={ isLinked ? link : linkOff }
iconSize={ 24 }
label={ label }
/>
);
}

0 comments on commit d516b23

Please sign in to comment.