Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions src/components/Page/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ export class Header extends React.PureComponent<HeaderProps, State> {
/>
);

const primary =
primaryAction &&
(primaryAction.primary === undefined ? true : primaryAction.primary);

const primaryActionMarkup = primaryAction ? (
<div className={styles.PrimaryActionWrapper}>
{buttonsFrom(primaryAction, {
primary: true,
})}
{buttonsFrom(primaryAction, {primary})}
</div>
) : null;

Expand Down
16 changes: 15 additions & 1 deletion src/components/Page/components/Header/tests/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('<Header />', () => {
});

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!',
};
Expand All @@ -99,6 +99,20 @@ describe('<Header />', () => {
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(
<Header {...mockProps} primaryAction={primaryAction} />,
);

const expectedButton = buttonsFrom(primaryAction, {primary: false});
expect(header.contains(expectedButton)).toBeTruthy();
});
});

describe('pagination', () => {
Expand Down