From 233ae6a5dfb6d190579b891f8c727e522a101de4 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 30 Sep 2022 11:57:31 -0700 Subject: [PATCH 1/5] [REVERT ME] Local reproduction of last breadcrumb issue - not respecting `truncate: true` on child breadcrumb when it should --- src-docs/src/views/breadcrumbs/truncate_single.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src-docs/src/views/breadcrumbs/truncate_single.js b/src-docs/src/views/breadcrumbs/truncate_single.js index 5aa30b1804b..6eb93162279 100644 --- a/src-docs/src/views/breadcrumbs/truncate_single.js +++ b/src-docs/src/views/breadcrumbs/truncate_single.js @@ -37,6 +37,7 @@ export default () => { { text: 'Nebulosa subspecies is also a real mouthful, especially for creatures without mouths', + truncate: true, }, ]; From 1d1a64688a133c7c856eee85263d933b0f9275af Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 30 Sep 2022 12:04:24 -0700 Subject: [PATCH 2/5] Fix last EuiBreadcrumb in array to respect `truncate: true` or `false` over parent `truncate` + minor opinioted change: don't allow `breadcrumb` objs coming in from consumers to override internal props coming in from EuiBreadcrumbs parent --- src/components/breadcrumbs/breadcrumb.tsx | 6 ++++-- src/components/breadcrumbs/breadcrumbs.tsx | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/breadcrumbs/breadcrumb.tsx b/src/components/breadcrumbs/breadcrumb.tsx index 895bc70966a..84a5c8c5941 100644 --- a/src/components/breadcrumbs/breadcrumb.tsx +++ b/src/components/breadcrumbs/breadcrumb.tsx @@ -63,6 +63,7 @@ type _EuiBreadcrumbProps = { isLastBreadcrumb?: boolean; isOnlyBreadcrumb?: boolean; highlightLastBreadcrumb?: boolean; + truncateLastBreadcrumb?: boolean; } & Pick; export const EuiBreadcrumb: FunctionComponent< @@ -100,6 +101,7 @@ export const EuiBreadcrumbContent: FunctionComponent< isLastBreadcrumb, isOnlyBreadcrumb, highlightLastBreadcrumb, + truncateLastBreadcrumb, ...rest }) => { const classes = classNames('euiBreadcrumb__content', className); @@ -109,8 +111,8 @@ export const EuiBreadcrumbContent: FunctionComponent< const cssStyles = [ styles.euiBreadcrumb__content, styles[type], - truncate && - (isLastBreadcrumb ? styles.isTruncatedLast : styles.isTruncated), + truncate && !truncateLastBreadcrumb && styles.isTruncated, + truncateLastBreadcrumb && styles.isTruncatedLast, ]; if (type === 'application') { if (isOnlyBreadcrumb) { diff --git a/src/components/breadcrumbs/breadcrumbs.tsx b/src/components/breadcrumbs/breadcrumbs.tsx index e2c978befa4..71d381982cd 100644 --- a/src/components/breadcrumbs/breadcrumbs.tsx +++ b/src/components/breadcrumbs/breadcrumbs.tsx @@ -120,7 +120,7 @@ export const EuiBreadcrumbs: FunctionComponent = ({ const isLastBreadcrumb = index === visibleBreadcrumbs.length - 1; const isOnlyBreadcrumb = visibleBreadcrumbs.length === 1; - const sharedProps = { type, truncate }; + const sharedProps = { type, truncate: breadcrumb.truncate ?? truncate }; return breadcrumb.isCollapsedButton ? ( = ({ ) : ( ); From dc1eeea5facb6d1646a1d00caab2b2e4f524a42c Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 30 Sep 2022 12:10:35 -0700 Subject: [PATCH 3/5] write a bunch of unit tests --- .../__snapshots__/breadcrumbs.test.tsx.snap | 63 +---------- .../breadcrumbs/breadcrumbs.test.tsx | 106 ++++++++++++++++-- 2 files changed, 99 insertions(+), 70 deletions(-) diff --git a/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap b/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap index 0796f578cdc..be1f13f5f1e 100644 --- a/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap +++ b/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap @@ -629,7 +629,7 @@ exports[`EuiBreadcrumbs props responsive is rendered with custom breakpoints 1`] `; -exports[`EuiBreadcrumbs props truncate as false is rendered 1`] = ` +exports[`EuiBreadcrumbs truncation setting truncate on breadcrumbs parents cascades down to all children 1`] = `