Skip to content

Commit 8cf54e7

Browse files
committed
Always display subtitle in Page
If a <Page> component only has subtitle has a property, the `hasHeaderContent` check will return false and no header will be rendered. With this commit we add the possiblility to render a header inside a Page if it only has `subtitle` set as a prop. We also amend the test to reflect that.
1 parent 432bdd5 commit 8cf54e7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function Page({
3333

3434
const hasHeaderContent =
3535
(rest.title != null && rest.title !== '') ||
36+
(rest.subtitle != null && rest.subtitle !== '') ||
3637
rest.primaryAction != null ||
3738
(rest.secondaryActions != null &&
3839
((isInterface(rest.secondaryActions) &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('<Page />', () => {
5858
describe('subtitle', () => {
5959
it('gets passed into the <Header />', () => {
6060
const subtitle = 'Subtitle';
61-
const page = mountWithApp(<Page {...mockProps} subtitle={subtitle} />);
61+
const page = mountWithApp(<Page subtitle={subtitle} />);
6262
expect(page).toContainReactComponent(Header, {
6363
subtitle,
6464
});

0 commit comments

Comments
 (0)