fix: improve BreadcrumbTrail truncation and layout within flexible panel headers by adjusting CSS and width calculation constants.
This commit is contained in:
@@ -3,5 +3,5 @@ export const DEFAULT_VIEWPORT_MARGIN = 8;
|
||||
|
||||
export const ELLIPSIS = { id: '__breadcrumbs_ellipsis__', label: '…', onClick: null, raw: null } as const;
|
||||
export const WIDTH_TOLERANCE = 1;
|
||||
export const WIDTH_BUFFER_RATIO = 0.95;
|
||||
export const WIDTH_CHANGE_TOLERANCE = 0.25;
|
||||
export const WIDTH_BUFFER_RATIO = 0.99;
|
||||
export const WIDTH_CHANGE_TOLERANCE = 0.02;
|
||||
|
||||
@@ -437,12 +437,14 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
|
||||
) : loadingSection;
|
||||
|
||||
const headerTitle = breadcrumbTrailEntries.length ? (
|
||||
<BreadcrumbTrail
|
||||
entries={breadcrumbTrailEntries}
|
||||
separator="/"
|
||||
className="panel-header__breadcrumbs"
|
||||
truncateFromStart={isSidebarVariant}
|
||||
/>
|
||||
<div className="panel-header__breadcrumbs-wrapper">
|
||||
<BreadcrumbTrail
|
||||
entries={breadcrumbTrailEntries}
|
||||
separator="/"
|
||||
className="panel-header__breadcrumbs"
|
||||
truncateFromStart={isSidebarVariant}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
document?.title || 'Document preview'
|
||||
);
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
}
|
||||
|
||||
.breadcrumb-trail__link {
|
||||
display: inline-flex;
|
||||
display: block;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
white-space: nowrap;
|
||||
@@ -83,6 +83,7 @@
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
cursor: default;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.breadcrumb-trail--measure .breadcrumb-trail__link,
|
||||
@@ -138,6 +139,11 @@ button.breadcrumb-trail__link,
|
||||
max-width: 22rem;
|
||||
}
|
||||
|
||||
.panel-header__breadcrumbs-wrapper {
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.panel-section__body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
@@ -148,4 +154,4 @@ button.breadcrumb-trail__link,
|
||||
.panel-section__body--scrollable,
|
||||
.panel-section__body.scrollable {
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ const BreadcrumbTrail = ({
|
||||
}
|
||||
|
||||
// Reserve a tiny buffer so the live trail doesn't oscillate when the
|
||||
// container width barely fits; shrink the measured allowance by 1%.
|
||||
// container width barely fits; shrink the measured allowance a bit.
|
||||
const adjustedAvailable = available * WIDTH_BUFFER_RATIO;
|
||||
|
||||
let nextStart = widths.length - 1;
|
||||
@@ -297,20 +297,20 @@ const BreadcrumbTrail = ({
|
||||
|
||||
const content = !entry.onClick || isLast
|
||||
? (
|
||||
<span key={`${entry.id}-label`} {...commonProps}>
|
||||
{entry.label}
|
||||
</span>
|
||||
)
|
||||
<span key={`${entry.id}-label`} {...commonProps}>
|
||||
{entry.label}
|
||||
</span>
|
||||
)
|
||||
: (
|
||||
<button
|
||||
key={`${entry.id}-button`}
|
||||
type="button"
|
||||
{...commonProps}
|
||||
onClick={() => entry.onClick?.(entry.raw ?? entry)}
|
||||
>
|
||||
{entry.label}
|
||||
</button>
|
||||
);
|
||||
<button
|
||||
key={`${entry.id}-button`}
|
||||
type="button"
|
||||
{...commonProps}
|
||||
onClick={() => entry.onClick?.(entry.raw ?? entry)}
|
||||
>
|
||||
{entry.label}
|
||||
</button>
|
||||
);
|
||||
|
||||
return (
|
||||
<React.Fragment key={entry.id || index}>
|
||||
@@ -371,33 +371,33 @@ const BreadcrumbTrail = ({
|
||||
&& hasHiddenEntries
|
||||
&& ellipsisMenuStyle
|
||||
? createPortal(
|
||||
<div
|
||||
className="menu menu--floating"
|
||||
role="menu"
|
||||
ref={ellipsisMenuRef}
|
||||
style={ellipsisMenuStyle}
|
||||
data-floating-position
|
||||
>
|
||||
<div className="menu__list">
|
||||
{hiddenEntries.map((hiddenEntry) => (
|
||||
<button
|
||||
key={hiddenEntry.id}
|
||||
type="button"
|
||||
className="menu__item"
|
||||
role="menuitem"
|
||||
onClick={() => {
|
||||
closeEllipsisMenu();
|
||||
hiddenEntry.onClick?.(hiddenEntry.raw ?? hiddenEntry);
|
||||
}}
|
||||
disabled={!hiddenEntry.onClick}
|
||||
>
|
||||
<span className="menu__label">{hiddenEntry.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
<div
|
||||
className="menu menu--floating"
|
||||
role="menu"
|
||||
ref={ellipsisMenuRef}
|
||||
style={ellipsisMenuStyle}
|
||||
data-floating-position
|
||||
>
|
||||
<div className="menu__list">
|
||||
{hiddenEntries.map((hiddenEntry) => (
|
||||
<button
|
||||
key={hiddenEntry.id}
|
||||
type="button"
|
||||
className="menu__item"
|
||||
role="menuitem"
|
||||
onClick={() => {
|
||||
closeEllipsisMenu();
|
||||
hiddenEntry.onClick?.(hiddenEntry.raw ?? hiddenEntry);
|
||||
}}
|
||||
disabled={!hiddenEntry.onClick}
|
||||
>
|
||||
<span className="menu__label">{hiddenEntry.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
: null}
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user