diff --git a/UNRELEASED.md b/UNRELEASED.md index a54ef68b532..91ceea5e2ba 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -19,6 +19,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f - Fixed `Modal` setting an invalid `id` on `aria-labelledby` when no `title` is set ([#2115](https://github.com/Shopify/polaris-react/pull/2115)) - Fixed error warnings in `Card` and `RollupActions` tests ([#2125](https://github.com/Shopify/polaris-react/pull/2125)) - Added default accessibility label from `ResourceItem` ([#2097](https://github.com/Shopify/polaris-react/pull/2097)) +- Reverted `Page.primaryAction` forcing `primary` to be `true` ([#2137](https://github.com/Shopify/polaris-react/pull/2137)) ### Documentation diff --git a/src/components/Page/components/Header/Header.tsx b/src/components/Page/components/Header/Header.tsx index 3c72a2147c9..bbe787488e8 100644 --- a/src/components/Page/components/Header/Header.tsx +++ b/src/components/Page/components/Header/Header.tsx @@ -114,11 +114,13 @@ export class Header extends React.PureComponent { /> ); + const primary = + primaryAction && + (primaryAction.primary === undefined ? true : primaryAction.primary); + const primaryActionMarkup = primaryAction ? (
- {buttonsFrom(primaryAction, { - primary: true, - })} + {buttonsFrom(primaryAction, {primary})}
) : null; diff --git a/src/components/Page/components/Header/tests/Header.test.tsx b/src/components/Page/components/Header/tests/Header.test.tsx index 87d8f8639b7..432095e518f 100644 --- a/src/components/Page/components/Header/tests/Header.test.tsx +++ b/src/components/Page/components/Header/tests/Header.test.tsx @@ -87,7 +87,7 @@ describe('
', () => { }); describe('primaryAction', () => { - it('renders a button based on the given action', () => { + it('renders a `primary` button based on the given action', () => { const primaryAction: HeaderPrimaryAction = { content: 'Click me!', }; @@ -99,6 +99,20 @@ describe('
', () => { const expectedButton = buttonsFrom(primaryAction, {primary: true}); expect(header.contains(expectedButton)).toBeTruthy(); }); + + it('renders a regular button based on the given action when primary is set to false', () => { + const primaryAction: HeaderPrimaryAction = { + content: 'Click me!', + primary: false, + }; + + const header = mountWithAppProvider( +
, + ); + + const expectedButton = buttonsFrom(primaryAction, {primary: false}); + expect(header.contains(expectedButton)).toBeTruthy(); + }); }); describe('pagination', () => {