Skip to content

Commit cc706f4

Browse files
authored
[PageActions] Group actions together (#8115)
### WHY are these changes introduced? There are inconsistencies across the admin in how related actions are grouped together. We usually group actions together, right-aligned as seen in the ContextualSaveBar below. <img width="2096" alt="Screenshot 2023-01-20 at 13 09 31" src="https://user-images.githubusercontent.com/2562596/213702476-0384360a-6255-4b78-82da-cc92e291e423.png"> The PageActions component places the secondary action justified left whilst the primary action is justified right. This PR removes that logic and always places the secondary action justified right, next to the primary action. <img width="1331" alt="Screenshot 2023-01-20 at 13 08 42" src="https://user-images.githubusercontent.com/2562596/213702643-6b4ca1a7-4e52-4c8a-a566-bf424e09f397.png"> ### 🎩 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 39704dc commit cc706f4

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

.changeset/nasty-olives-call.md

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+
Grouped PageActions actions at the trailing edge of the container

polaris-react/src/components/PageActions/PageActions.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ export function PageActions({
4242
secondaryActionsMarkup = <>{secondaryActions}</>;
4343
}
4444

45-
const distribution = secondaryActionsMarkup ? 'equalSpacing' : 'trailing';
46-
4745
return (
4846
<div className={styles.PageActions}>
49-
<Stack distribution={distribution} spacing="tight">
47+
<Stack distribution="trailing" spacing="tight">
5048
{secondaryActionsMarkup}
5149
{primaryActionMarkup}
5250
</Stack>

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@ describe('<PageActions />', () => {
1818
expect(pageActions).toContainReactComponentTimes(Stack, 1);
1919
});
2020

21-
it('uses equalSpacing distribution if secondaryActions are provided', () => {
22-
const mockActions = [{content: 'Delete'}];
23-
24-
const pageActions = mountWithApp(
25-
<PageActions secondaryActions={mockActions} />,
26-
);
27-
const stack = pageActions.find(Stack);
28-
expect(stack).toHaveReactProps({
29-
distribution: 'equalSpacing',
30-
});
31-
});
32-
33-
it('uses trailing distribution if secondaryActions are not provided', () => {
34-
const pageActions = mountWithApp(<PageActions />);
35-
const stack = pageActions.find(Stack);
36-
expect(stack).toHaveReactProps({
37-
distribution: 'trailing',
38-
});
39-
});
40-
4121
it('passes spacing tight to Stack', () => {
4222
const pageActions = mountWithApp(<PageActions />);
4323
const stack = pageActions.find(Stack);

0 commit comments

Comments
 (0)