fix(ui): keep room popovers and attachment names readable

Use the shared button and anchored-popover owners for narrow file cards and inset room surfaces. Keep draggable panels bounded by their window. Verified actual Chrome layouts at 390, 1360 and 1680 pixels, keyboard and touch actions; Native frame geometry was simulated in Chrome.
This commit is contained in:
AAA committed 2026-11-27 13:45:55 -05:00
1 parent b3dc789bf9
commit dc45b2affb
5 files changed
+29 -10

No files matched your search

@@ -5,6 +5,7 @@ import type { ChannelAttachment as Attachment, ImageRendition } from "../protoco
import { attachmentDownloadDocument, type ChannelAttachments, fileSize, isNativeSavePending } from "../attachments";
import { inlineImageFile } from "../image-preview";
import { ChannelAction } from "./ChannelAction";
import { Btn } from "../../components/living/primitives";
import { Tooltip } from "../../components/living/Tooltip";
import { ChannelImageDialog } from "./ChannelImageDialog";
import { channelErrorPresentation } from "../../components/error-presentation";
@@ -151,6 +152,7 @@ export function ChannelAttachment({ roomId, messageSeq, file, client, inlineImag
const canReveal = savedCopy && typeof attachmentDownloadDocument(surfaceDocument)?.defaultView?.piikRevealDownload === "function";
const canRetryDownload = !unavailable && downloadError &&
!["file_offer_failed", "reveal_saved_copy_failed", "saved_copy_missing"].includes(downloadError);
const downloadControlBusy = savePending || (revealing && !download.busy);
const downloadLabel = download.busy ? t("channel.attachment.cancelDownload")
: savePending ? t(saving ? "channel.attachment.saving" : "channel.attachment.downloadRequested")
: canReveal ? t("channel.attachment.revealSaved")
@@ -168,10 +170,10 @@ export function ChannelAttachment({ roomId, messageSeq, file, client, inlineImag
return <div className="c3-attachment" ref={downloadSurface}>
<div className="c3-attachment-file"><Glyph name={saved ? "check" : "fileDown"} size={21} />
<div><Tooltip overflow={{ text: file.name, selector: "strong" }}><strong>{file.name}</strong></Tooltip><small>{fileSize(file.size)}</small></div>
<ChannelAction icon={download.busy ? "x" : canReveal ? "folder" : canRetryDownload ? "refresh" : "arrowDown"}
label={downloadLabel} accessibleLabel={labelForFile(downloadLabel)}
quiet iconOnly={savePending} busy={savePending || (revealing && !download.busy)}
disabled={unavailable && !download.busy && !savePending && !canReveal}
<Btn icon={download.busy ? "x" : canReveal ? "folder" : canRetryDownload ? "refresh" : "arrowDown"}
title={{ text: labelForFile(downloadLabel) }} cap={savePending ? undefined : { text: downloadLabel }} capOverflowTooltip
quiet size="compact" busy={downloadControlBusy}
disabled={downloadControlBusy || (unavailable && !download.busy && !canReveal)}
onClick={() => {
if (download.busy) { client.cancelDownload(key); return; }
const surface = downloadSurface.current;
@@ -19,7 +19,7 @@ export function ChannelRoomInvitation({ channel, room, onManageAccess }: {
const id = useId(), trigger = useRef<HTMLSpanElement>(null), panel = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
const label = t("invite.room.title", { name: room.name });
useAnchoredPopover(trigger, panel, { maxHeight: 560 });
useAnchoredPopover(trigger, panel, { align: "start", maxHeight: 560 });
useLayerHistory(panel, open);
return <span className="c3-room-invitation-entry" ref={trigger}>
<Btn icon="link" title={{ text: label }} textTooltip quiet size="compact" expanded={open} controls={id} popoverTarget={id} />
@@ -102,8 +102,13 @@
.c3-attachment-file { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.c3-attachment-file > svg { flex: none; color: var(--muted); }
.c3-attachment-file > div { flex: 1 1 8ch; min-width: 0; }
.c3-attachment-file .lr-comic-tip-wrap { display: block; }
.c3-attachment-file strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.c3-attachment-file > div > .lr-comic-tip-wrap { display: block; }
.c3-attachment-file strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; }
@container conversation (max-width: 360px) {
.c3-attachment-file > .lr-comic-tip-wrap > .lr-btn { --button-padding: 0; }
/* Keep the caption measurable by the shared overflow tooltip. */
.c3-attachment-file > .lr-comic-tip-wrap .lr-cap { position: absolute; inline-size: 0; overflow: hidden; margin: 0; }
}
.c3-attachment small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.c3-attachment > .lr-btn { justify-self: start; }
.c3-attachment img { display: block; max-width: 100%; max-height: 260px; border-radius: max(0px, calc(var(--c3-inset-radius) - 10px)); object-fit: contain; }
+7 -1
View File
@@ -47,6 +47,7 @@ export function Btn({
autoFocus,
icon,
cap,
capOverflowTooltip,
tone,
size,
quiet = false,
@@ -78,6 +79,8 @@ export function Btn({
autoFocus?: boolean;
icon: GlyphName;
cap?: ControlCopy;
/** Show guidance if the visible caption is clipped or condensed by CSS. */
capOverflowTooltip?: boolean;
tone?: "primary" | "danger" | "on";
size?: "compact" | "dense";
quiet?: boolean;
@@ -111,6 +114,7 @@ export function Btn({
}) {
const { t } = useCopy();
const label = typeof title === "string" ? t(title) : title.text;
const caption = capOverflowTooltip && (typeof cap === "string" ? t(cap) : cap?.text);
const wrapped = Boolean(hint || textTooltip);
const softDisabled = Boolean(wrapped && disabled);
const activeTone = tone ?? (pressed ? "on" : undefined);
@@ -154,7 +158,9 @@ export function Btn({
);
return hint ? (
<Tooltip kind={hint} disabled={expanded} tone={hintTone} motion={hintMotion} place={hintPlace} align={hintAlign} text={hintText ? t(hintText, hintVars) : label}>{button}</Tooltip>
) : textTooltip ? <Tooltip text={shortcutLabel ? label + " · " + shortcutLabel : label} disabled={expanded}>{button}</Tooltip> : (
) : textTooltip ? <Tooltip text={shortcutLabel ? label + " · " + shortcutLabel : label} disabled={expanded}>{button}</Tooltip> : caption ? (
<Tooltip overflow={{ text: caption, selector: ".lr-cap" }} disabled={expanded}>{button}</Tooltip>
) : (
button
);
}
@@ -2,6 +2,8 @@ import { useLayoutEffect, useRef, type RefObject } from "react";
import { useSurfaceDocument } from "../../ui/panel-window";
import { surfaceViewport } from "../../ui/window-appearance";
const roomWorkspace = (anchor: HTMLElement) => anchor.closest<HTMLElement>('[data-app-shell][data-layout="living"]');
// Place the native popover beside its anchor. Nested callers can supply a
// return target for when the browser leaves focus behind in the closing layer.
export function useAnchoredPopover(
@@ -32,8 +34,10 @@ export function useAnchoredPopover(
if (!anchor || !menu.matches(":popover-open")) return;
const rect = anchor.getBoundingClientRect();
const bounds = surfaceViewport(menu.ownerDocument);
const left = bounds.left + 8, top = bounds.top + 8;
const right = bounds.right - 8, bottom = bounds.bottom - 8;
const workspace = roomWorkspace(anchor);
const room = workspace?.checkVisibility({ visibilityProperty: true }) ? workspace.getBoundingClientRect() : bounds;
const left = Math.max(bounds.left, room.left) + 8, top = Math.max(bounds.top, room.top) + 8;
const right = Math.min(bounds.right, room.right) - 8, bottom = Math.min(bounds.bottom, room.bottom) - 8;
// Placement insets do not make a visible anchor offscreen.
const anchorOutside = rect.bottom < (viewport?.offsetTop ?? 0) || rect.top > bounds.bottom
|| rect.right < bounds.left || rect.left > bounds.right;
@@ -94,6 +98,8 @@ export function useAnchoredPopover(
const anchor = trigger.current;
if (anchor) {
observer.observe(anchor);
const workspace = roomWorkspace(anchor);
if (workspace) observer.observe(workspace);
visibility?.observe(anchor);
}
const parentPopover = anchor?.closest("[popover]");