mirror of
https://github.com/block/buzz.git
synced 2026-11-30 05:02:57 +00:00
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 — after** (truncates with ellipsis, controls stay clear):  **Author name — before** (long name runs past the header row edge):  **Author name — after** (clean cutoff):  🤖 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:
@@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user