Skip to content

Commit 9c53d39

Browse files
Revert "[Breadcrumbs] Allow breadcrumbs to be singular (#8016)"
This reverts commit ca77f0b.
1 parent d74c391 commit 9c53d39

File tree

6 files changed

+6
-51
lines changed

6 files changed

+6
-51
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import styles from './Breadcrumbs.scss';
1111

1212
export interface BreadcrumbsProps {
1313
/** Collection of breadcrumbs */
14-
breadcrumbs: (CallbackAction | LinkAction) | (CallbackAction | LinkAction)[];
14+
breadcrumbs: (CallbackAction | LinkAction)[];
1515
}
1616

1717
export function Breadcrumbs({breadcrumbs}: BreadcrumbsProps) {
18-
const breadcrumb = Array.isArray(breadcrumbs)
19-
? breadcrumbs[breadcrumbs.length - 1]
20-
: breadcrumbs;
18+
const breadcrumb = breadcrumbs[breadcrumbs.length - 1];
2119
if (breadcrumb == null) {
2220
return null;
2321
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,6 @@ describe('<Breadcrumbs />', () => {
109109
});
110110
});
111111

112-
it('renders when not passed an array', () => {
113-
const breadcrumb: LinkAction = {
114-
content: 'Products',
115-
url: 'https://www.shopify.com',
116-
};
117-
const wrapper = mountWithApp(<Breadcrumbs breadcrumbs={breadcrumb} />);
118-
119-
expect(wrapper.html()).not.toBe('');
120-
});
121-
122112
it('renders nothing when empty', () => {
123113
const wrapper = mountWithApp(<Breadcrumbs breadcrumbs={[]} />);
124114

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ export function Page({
4040
rest.secondaryActions.length > 0) ||
4141
isReactElement(rest.secondaryActions))) ||
4242
(rest.actionGroups != null && rest.actionGroups.length > 0) ||
43-
(rest.breadcrumbs != null &&
44-
Array.isArray(rest.breadcrumbs) &&
45-
rest.breadcrumbs.length > 0) ||
46-
rest.breadcrumbs != null;
43+
(rest.breadcrumbs != null && rest.breadcrumbs.length > 0);
4744

4845
const contentClassName = classNames(
4946
!hasHeaderContent && styles.Content,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function Header({
7474
primaryAction,
7575
pagination,
7676
additionalNavigation,
77-
breadcrumbs,
77+
breadcrumbs = [],
7878
secondaryActions = [],
7979
actionGroups = [],
8080
compactTitle = false,
@@ -98,8 +98,7 @@ export function Header({
9898
!actionGroups.length;
9999

100100
const breadcrumbMarkup =
101-
(Array.isArray(breadcrumbs) && breadcrumbs.length > 0) ||
102-
(!Array.isArray(breadcrumbs) && breadcrumbs) ? (
101+
breadcrumbs.length > 0 ? (
103102
<div className={styles.BreadcrumbWrapper}>
104103
<Breadcrumbs breadcrumbs={breadcrumbs} />
105104
</div>
@@ -179,7 +178,7 @@ export function Header({
179178
navigationMarkup && styles.hasNavigation,
180179
actionMenuMarkup && styles.hasActionMenu,
181180
isNavigationCollapsed && styles.mobileView,
182-
!breadcrumbMarkup && styles.noBreadcrumbs,
181+
!breadcrumbs.length && styles.noBreadcrumbs,
183182
title && title.length < LONG_TITLE && styles.mediumTitle,
184183
title && title.length > LONG_TITLE && styles.longTitle,
185184
);

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,6 @@ describe('<Header />', () => {
6262
breadcrumbs,
6363
});
6464
});
65-
66-
it('renders breadcrumb markup if not an array', () => {
67-
const breadcrumb: LinkAction = {
68-
content: 'Products',
69-
url: 'https://www.google.com',
70-
};
71-
const header = mountWithApp(
72-
<Header {...mockProps} breadcrumbs={breadcrumb} />,
73-
);
74-
expect(header).toContainReactComponent(Breadcrumbs, {
75-
breadcrumbs: breadcrumb,
76-
});
77-
});
78-
79-
it('does not render breadcrumb markup if no breadcrumbs', () => {
80-
const header = mountWithApp(<Header {...mockProps} />);
81-
expect(header).not.toContainReactComponent(Breadcrumbs);
82-
});
8365
});
8466

8567
describe('primaryAction', () => {

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,6 @@ describe('<Page />', () => {
248248
expect(page).toContainReactComponent(Header);
249249
});
250250

251-
it('renders a <Header /> when defined not as an array', () => {
252-
const breadcrumbs = {
253-
content: 'Products',
254-
onAction: noop,
255-
};
256-
const page = mountWithApp(
257-
<Page {...mockProps} breadcrumbs={breadcrumbs} />,
258-
);
259-
expect(page).toContainReactComponent(Header);
260-
});
261-
262251
it('gets passed into the <Header />', () => {
263252
const page = mountWithApp(
264253
<Page {...mockProps} breadcrumbs={breadcrumbs} />,

0 commit comments

Comments
 (0)