From dc45b2affb05c812e092216e85dbf6715dca2d9c Mon Sep 17 00:00:00 2001
From: AAA <35992542+TNTcraftHIM@users.noreply.github.com>
Date: Fri, 27 Nov 2026 13:45:55 -0500
Subject: [PATCH] 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.
---
src/client/channel/components/ChannelAttachment.tsx | 10 ++++++----
.../channel/components/ChannelRoomInvitation.tsx | 2 +-
src/client/channel/components/channel-conversation.css | 9 +++++++--
src/client/components/living/primitives.tsx | 8 +++++++-
src/client/components/living/use-anchored-popover.ts | 10 ++++++++--
5 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/client/channel/components/ChannelAttachment.tsx b/src/client/channel/components/ChannelAttachment.tsx
index d8e5680a6..65611d748 100644
--- a/src/client/channel/components/ChannelAttachment.tsx
+++ b/src/client/channel/components/ChannelAttachment.tsx
@@ -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
{file.name}{fileSize(file.size)}
-
{
if (download.busy) { client.cancelDownload(key); return; }
const surface = downloadSurface.current;
diff --git a/src/client/channel/components/ChannelRoomInvitation.tsx b/src/client/channel/components/ChannelRoomInvitation.tsx
index 68577b74a..4f49a583b 100644
--- a/src/client/channel/components/ChannelRoomInvitation.tsx
+++ b/src/client/channel/components/ChannelRoomInvitation.tsx
@@ -19,7 +19,7 @@ export function ChannelRoomInvitation({ channel, room, onManageAccess }: {
const id = useId(), trigger = useRef(null), panel = useRef(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
diff --git a/src/client/channel/components/channel-conversation.css b/src/client/channel/components/channel-conversation.css
index e8a33ebff..56e420ce3 100644
--- a/src/client/channel/components/channel-conversation.css
+++ b/src/client/channel/components/channel-conversation.css
@@ -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; }
diff --git a/src/client/components/living/primitives.tsx b/src/client/components/living/primitives.tsx
index 58aac9553..86b177a35 100644
--- a/src/client/components/living/primitives.tsx
+++ b/src/client/components/living/primitives.tsx
@@ -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 ? (
{button}
- ) : textTooltip ? {button} : (
+ ) : textTooltip ? {button} : caption ? (
+ {button}
+ ) : (
button
);
}
diff --git a/src/client/components/living/use-anchored-popover.ts b/src/client/components/living/use-anchored-popover.ts
index 9eb72e5d6..b59612544 100644
--- a/src/client/components/living/use-anchored-popover.ts
+++ b/src/client/components/living/use-anchored-popover.ts
@@ -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('[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]");