Skip to content

Commit 6d47345

Browse files
authored
[BulkActions] Add Tooltip to more actions button (#8912)
### WHY are these changes introduced? Fixes Shopify/web#87957 Signposts the intent of the horizontal dot menu more clearly for greater ease of understanding. ### WHAT is this pull request doing? This PR introduces a Tooltip that wraps the activator button in the BulkActions component which opens up the Popover containing the additional bulk actions not rendered by default as promoted bulk actions. <img width="1963" alt="Screenshot 2023-04-11 at 10 25 46" src="https://user-images.githubusercontent.com/2562596/231116970-4f34b3ec-f4eb-4cc3-859d-203350af6315.png"> Spinstance: https://admin.web.bulk-actions-tooltip.marc-thomas.eu.spin.dev/store/shop1/products?selectedView=all ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent ee7c076 commit 6d47345

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Updated `BulkActions` to include wrapping tooltip on Popover activator

polaris-react/src/components/BulkActions/components/BulkActionButton/BulkActionButton.tsx

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {DisableableAction} from '../../../../types';
55
import {Button} from '../../../Button';
66
import {Icon} from '../../../Icon';
77
import {Indicator} from '../../../Indicator';
8+
import {Tooltip} from '../../../Tooltip';
89
import {useComponentDidMount} from '../../../../utilities/use-component-did-mount';
910
import styles from '../../BulkActions.scss';
1011

@@ -36,29 +37,40 @@ export function BulkActionButton({
3637
}
3738
});
3839

39-
const buttonContent =
40-
disclosure && !showContentInButton ? undefined : content;
40+
const isActivatorForMoreActionsPopover = disclosure && !showContentInButton;
41+
42+
const buttonContent = isActivatorForMoreActionsPopover ? undefined : content;
43+
44+
const buttonMarkup = (
45+
<Button
46+
external={external}
47+
url={url}
48+
accessibilityLabel={
49+
isActivatorForMoreActionsPopover ? content : accessibilityLabel
50+
}
51+
disclosure={disclosure && showContentInButton}
52+
onClick={onAction}
53+
disabled={disabled}
54+
size="slim"
55+
icon={
56+
isActivatorForMoreActionsPopover ? (
57+
<Icon source={HorizontalDotsMinor} color="base" />
58+
) : undefined
59+
}
60+
>
61+
{buttonContent}
62+
</Button>
63+
);
4164

4265
return (
4366
<div className={styles.BulkActionButton} ref={bulkActionButton}>
44-
<Button
45-
external={external}
46-
url={url}
47-
accessibilityLabel={
48-
disclosure && !showContentInButton ? content : accessibilityLabel
49-
}
50-
disclosure={disclosure && showContentInButton}
51-
onClick={onAction}
52-
disabled={disabled}
53-
size="slim"
54-
icon={
55-
disclosure && !showContentInButton ? (
56-
<Icon source={HorizontalDotsMinor} color="base" />
57-
) : undefined
58-
}
59-
>
60-
{buttonContent}
61-
</Button>
67+
{isActivatorForMoreActionsPopover ? (
68+
<Tooltip content={content} preferredPosition="above">
69+
{buttonMarkup}
70+
</Tooltip>
71+
) : (
72+
buttonMarkup
73+
)}
6274
{indicator && <Indicator />}
6375
</div>
6476
);

polaris-react/src/components/BulkActions/tests/BulkActions.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Transition, CSSTransition} from 'react-transition-group';
33
import {mountWithApp} from 'tests/utilities';
44

55
import {ActionList} from '../../ActionList';
6+
import {Tooltip} from '../../Tooltip';
67
import {BulkActionButton, BulkActionMenu} from '../components';
78
import type {BulkActionButtonProps} from '../components';
89
import {BulkActions} from '../BulkActions';
@@ -307,4 +308,24 @@ describe('<BulkActions />', () => {
307308
});
308309
});
309310
});
311+
312+
describe('more actions', () => {
313+
it('will be wrapped in a tooltip', () => {
314+
const manyBulkActions = [
315+
{content: 'Action'},
316+
{content: 'Action 2'},
317+
{content: 'Action 3'},
318+
{content: 'Action 4'},
319+
{content: 'Action 5'},
320+
{content: 'Action 6'},
321+
];
322+
const bulkActions = mountWithApp(
323+
<BulkActions {...bulkActionProps} actions={manyBulkActions} />,
324+
);
325+
326+
expect(bulkActions).toContainReactComponent(Tooltip, {
327+
content: 'More actions',
328+
});
329+
});
330+
});
310331
});

0 commit comments

Comments
 (0)