diff --git a/changelogs/upcoming/7375.md b/changelogs/upcoming/7375.md new file mode 100644 index 00000000000..63611add618 --- /dev/null +++ b/changelogs/upcoming/7375.md @@ -0,0 +1,3 @@ +**Bug fixes** + +- Fixed visual text truncation of `EuiBreadcrumb`s with `popoverContent` diff --git a/src-docs/src/views/breadcrumbs/popover_content.tsx b/src-docs/src/views/breadcrumbs/popover_content.tsx index e148ec85066..f5ab29a0198 100644 --- a/src-docs/src/views/breadcrumbs/popover_content.tsx +++ b/src-docs/src/views/breadcrumbs/popover_content.tsx @@ -33,7 +33,7 @@ export default () => { prepend: , }, { - label: "Dwight's space", + label: "Assistant Manager Dwight's space", prepend: , }, ]); @@ -75,10 +75,10 @@ export default () => { popoverProps: { panelPaddingSize: 'none' }, }, { - text: 'My space', + text: spaces.find((space) => space.checked === 'on')!.label, popoverContent: ( setSpaces(newOptions)} searchable diff --git a/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap b/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap index 0fb3af824a7..5a803bb40ce 100644 --- a/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap +++ b/src/components/breadcrumbs/__snapshots__/breadcrumb.test.tsx.snap @@ -4,17 +4,20 @@ exports[`EuiBreadcrumbContent renders breadcrumbs with \`popoverContent\` with p - Toggles a popover - + + Toggles a popover + diff --git a/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap b/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap index 5cdb3484794..27252750a54 100644 --- a/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap +++ b/src/components/breadcrumbs/__snapshots__/breadcrumbs.test.tsx.snap @@ -39,19 +39,22 @@ exports[`EuiBreadcrumbs is rendered 1`] = ` data-test-subj="euiBreadcrumb" > - … + + … + - @@ -140,19 +143,22 @@ exports[`EuiBreadcrumbs is rendered with final item as link 1`] = ` data-test-subj="euiBreadcrumb" > - … + + … + - @@ -323,19 +329,22 @@ exports[`EuiBreadcrumbs props max renders 1 item 1`] = ` data-test-subj="euiBreadcrumb" > - … + + … + - @@ -505,19 +514,22 @@ exports[`EuiBreadcrumbs props responsive is rendered 1`] = ` data-test-subj="euiBreadcrumb" > - … + + … + - @@ -605,19 +617,22 @@ exports[`EuiBreadcrumbs props responsive is rendered as false 1`] = ` data-test-subj="euiBreadcrumb" > - … + + … + - @@ -680,19 +695,22 @@ exports[`EuiBreadcrumbs props responsive is rendered with custom breakpoints 1`] data-test-subj="euiBreadcrumb" > - … + + … + - diff --git a/src/components/breadcrumbs/breadcrumb.styles.ts b/src/components/breadcrumbs/breadcrumb.styles.ts index a9a9b291ba1..2950c4951e9 100644 --- a/src/components/breadcrumbs/breadcrumb.styles.ts +++ b/src/components/breadcrumbs/breadcrumb.styles.ts @@ -80,6 +80,21 @@ export const euiBreadcrumbContentStyles = (euiThemeContext: UseEuiTheme) => { ${euiTextTruncate('none')} `, + // Popover styles + euiBreadcrumb__popoverButton: css` + max-inline-size: 100%; + display: inline-flex; + align-items: center; + gap: ${euiTheme.size.xs}; + `, + euiBreadcrumb__popoverWrapper: css` + /* At small container widths, the popover anchor needs to leave room for the breadcrumb separator, + which is weird to get an exact width for because it's transformed at an angle */ + max-inline-size: calc( + 100% - ${mathWithUnits(euiTheme.size.base, (x) => x + 1)} + ); + `, + // Types page: css` &:is(a):focus { diff --git a/src/components/breadcrumbs/breadcrumb.tsx b/src/components/breadcrumbs/breadcrumb.tsx index 2d5d927c4e5..5730e219dc3 100644 --- a/src/components/breadcrumbs/breadcrumb.tsx +++ b/src/components/breadcrumbs/breadcrumb.tsx @@ -162,13 +162,8 @@ export const EuiBreadcrumbContent: FunctionComponent< {(ref, innerText) => { const title = innerText === '' ? undefined : innerText; - const sharedProps = { - ref, - title, - 'aria-current': ariaCurrent, - className: classes, - css: cssStyles, - }; + const baseProps = { ref, title, 'aria-current': ariaCurrent }; + const styleProps = { className: classes, css: cssStyles }; if (isPopoverBreadcrumb) { return ( @@ -176,15 +171,17 @@ export const EuiBreadcrumbContent: FunctionComponent< {...popoverProps} isOpen={isPopoverOpen} closePopover={() => setIsPopoverOpen(false)} + css={!isLastBreadcrumb && styles.euiBreadcrumb__popoverWrapper} button={ setIsPopoverOpen((isOpen) => !isOpen)} {...rest} > - {text}{' '} + {text} - + {text}