fix(desktop): let inbox title and message author names truncate under narrow panes (#7550)

## Summary

Fixes two instances of the same dead-truncate pattern in the desktop
app, where a flex item's implicit `min-width: auto` prevented `truncate`
from engaging, so long text painted over adjacent controls instead of
ellipsizing:

- **Inbox detail title** (`InboxDetailPane.tsx`): the clickable
context-title button sized to its text instead of shrinking with the
pane, overlapping the header controls (open-in-channel, members, huddle,
more menu). Fixed by adding `max-w-full`.
- **Message author names** (`MessageHeader.tsx` /
`UserProfilePopover.tsx`): the `UserProfilePopover` inline-flex trigger
wrapper refused to shrink below the name's nowrap width, running long
author names under the hover action bar and off the pane edge. Fixed by
adding a `triggerClassName` prop to `UserProfilePopover` and passing
`min-w-0 max-w-full` at the author call site.

Two other suspected instances (project file breadcrumb, drafts pane
title) were stress-tested and already truncate correctly — no change.

### Related issue

N/A — none found.

### Testing

- New Playwright regression tests for both fixes
(`inbox-title-overlap.spec.ts`, `message-author-overlap.spec.ts`,
registered in the smoke project), each proven to discriminate: they fail
with the fix reverted (real measured overlap) and assert the ellipsis
actually engages with non-zero title width, so they can't pass
vacuously.
- Typecheck, lint, and full desktop unit suite green (pre-push hooks);
full desktop e2e smoke suite run earlier: 1402 passed, 3 pre-existing
unrelated failures (each fails identically with the fix reverted).

**Inbox title — before** (long title paints under the header controls):

![Inbox title before: title text overlaps the header control
icons](https://github.com/user-attachments/assets/d5a10f98-114f-4466-8012-468616b82807)

**Inbox title — after** (truncates with ellipsis, controls stay clear):

![Inbox title after: title truncates with an ellipsis before the
controls](https://github.com/user-attachments/assets/80520f7c-1120-4dbc-929d-1ef5eceb874b)

**Author name — before** (long name runs past the header row edge):

![Author name before: name glyphs bleed past the action
bar](https://github.com/user-attachments/assets/be9743ae-ef51-4db0-8c46-a0649e98f0d5)

**Author name — after** (clean cutoff):

![Author name after: name truncates cleanly inside the header
row](https://github.com/user-attachments/assets/24cc0412-ca99-40c4-add6-13380b3ae065)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: cynfria <yescynthia@gmail.com>
Signed-off-by: Tree Trunks <6ba22921d9dc2ad0aa6ecdf63787ddd24726e266d866da31af69f2e4e146ace5@buzz.block.builderlab.xyz>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Tree Trunks <6ba22921d9dc2ad0aa6ecdf63787ddd24726e266d866da31af69f2e4e146ace5@buzz.block.builderlab.xyz>
This commit is contained in:
cynfria
2026-09-10 10:00:15 -07:00
committed by GitHub
parent 051c3a270b
commit cec5c8fd92
10 changed files with 398 additions and 8 deletions

View File

@@ -29,3 +29,35 @@ export function observeElementBlockSize(
observer.disconnect();
};
}
/**
* Reads the inline size from a ResizeObserver entry, preferring border-box
* size when available.
*/
export function readElementInlineSize(entry: ResizeObserverEntry): number {
return entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;
}
/**
* Invokes `onSize` immediately and whenever the observed element's inline size
* changes. Returns a cleanup function that disconnects the observer.
*/
export function observeElementInlineSize(
element: HTMLElement,
onSize: (size: number) => void,
): () => void {
onSize(element.getBoundingClientRect().width);
if (typeof ResizeObserver === "undefined") {
return () => {};
}
const observer = new ResizeObserver(([entry]) => {
onSize(readElementInlineSize(entry));
});
observer.observe(element);
return () => {
observer.disconnect();
};
}

View File

@@ -1,9 +1,14 @@
import * as React from "react";
import { observeElementBlockSize } from "./observeElementBlockSize";
import {
observeElementBlockSize,
observeElementInlineSize,
} from "./observeElementBlockSize";
type UseMeasuredCssVariableArgs = {
cssVariable: string;
/** Which box dimension to observe. Defaults to `"block"` (height). */
dimension?: "block" | "inline";
enabled?: boolean;
resetKey?: unknown;
resetValue: string;
@@ -11,9 +16,9 @@ type UseMeasuredCssVariableArgs = {
};
/**
* Observes an element's block size and writes it as a CSS custom property on a
* target element. Uses `useLayoutEffect` so the first measurement happens
* before paint.
* Observes an element's block (or inline) size and writes it as a CSS custom
* property on a target element. Uses `useLayoutEffect` so the first
* measurement happens before paint.
*
* Returns a callback ref for the source element. Attach it instead of a ref
* object so the measurement re-runs when the source mounts later than this
@@ -22,6 +27,7 @@ type UseMeasuredCssVariableArgs = {
export function useMeasuredCssVariable({
targetRef,
cssVariable,
dimension = "block",
resetValue,
resetKey,
enabled = true,
@@ -53,13 +59,25 @@ export function useMeasuredCssVariable({
targetEl.style.setProperty(cssVariable, `${px}px`);
};
const disconnect = observeElementBlockSize(sourceEl, applySize);
const observe =
dimension === "inline"
? observeElementInlineSize
: observeElementBlockSize;
const disconnect = observe(sourceEl, applySize);
return () => {
disconnect();
targetEl.style.setProperty(cssVariable, resetValue);
};
}, [sourceEl, targetRef, cssVariable, resetValue, resetKey, enabled]);
}, [
sourceEl,
targetRef,
cssVariable,
dimension,
resetValue,
resetKey,
enabled,
]);
return setSourceEl;
}