Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2634 from teamleadercrm/TIDAL-4359-allow-tooltipp…
Browse files Browse the repository at this point in the history
…ed-menu-items

Allow tooltipped menu items in split buttons
  • Loading branch information
lorgan3 authored Apr 25, 2023
2 parents 5545515 + 5531642 commit ce10c24
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

### Dependency updates

## [21.0.2] - 2023-04-25

### Fixed

- `SplitButton`: Render all elements passed to SplitButton instead of only MenuItems ([@lorgan3](https://https://github.com/lorgan3) in [#2634](https://github.com/teamleadercrm/ui/pull/2634))

## [21.0.1] - 2023-04-19

### Fixed
Expand Down Expand Up @@ -41,7 +47,6 @@

- [BREAKING] `@teamleader/ui-colors` has been updated to version 2.0.0 which uses the newer comma-free syntax for hsl colors. This means that you need to update the syntax where you use the hsl value in combination with alhpa (e.g. `hsl(var(--color-teal), 50%)` should be changed to `hsl(var(--color-teal) /50%)`). ([@lowiebenoot](https://https://github.com/lowiebenoot) in [#2620](https://github.com/teamleadercrm/ui/pull/2620))


## [20.1.0] - 2023-03-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@teamleader/ui",
"description": "Teamleader UI library",
"version": "21.0.1",
"version": "21.0.2",
"author": "Teamleader <[email protected]>",
"bugs": {
"url": "https://github.com/teamleadercrm/ui/issues"
Expand Down
10 changes: 5 additions & 5 deletions src/components/splitButton/SplitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ const SplitButton: GenericComponent<SplitButtonProps> = ({
>
<Menu>
{React.Children.map(children, (child) => {
if (
!React.isValidElement(child) ||
!isComponentOfType(MenuItem, child) ||
child.props.label === buttonLabel
) {
if (!React.isValidElement(child) || !isComponentOfType(MenuItem, child)) {
return child;
}

if (child.props.label === buttonLabel) {
return null;
}

Expand Down
14 changes: 14 additions & 0 deletions src/components/splitButton/splitButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import SplitButton from './SplitButton';
import MenuDivider from '../menu/MenuDivider';
import MenuItem from '../menu/MenuItem';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import Tooltip from '../tooltip';
import Box from '../box';
import { TextBody } from '../typography';

const handleButtonClick = () => {
console.log('clicked main button');
Expand Down Expand Up @@ -33,3 +36,14 @@ export const WithPopoverOverrides: ComponentStory<typeof SplitButton> = (args) =
<MenuItem onClick={handleMenuItemClick} label="I appear above the button" />
</SplitButton>
);

const TooltippedBox = Tooltip(Box);

export const WithTooltip: ComponentStory<typeof SplitButton> = (args) => (
<SplitButton {...args} onButtonClick={handleButtonClick}>
<MenuItem onClick={handleMenuItemClick} label="Main action" />
<TooltippedBox tooltip={<TextBody>I am disabled</TextBody>}>
<MenuItem onClick={handleMenuItemClick} label="Disabled action" disabled />
</TooltippedBox>
</SplitButton>
);

0 comments on commit ce10c24

Please sign in to comment.