fix(message): gate "Copy Text" to textual message types

Review noted media without a caption has a filename body, so Copy Text showed
and copied the filename. Gate to m.text/m.emote/m.notice so it only appears for
actual text messages (matching the intended behavior).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 16:20:58 -04:00
co-authored by Claude Opus 4.8
parent 12aa49f054
commit 4d78d427d2
+5 -1
View File
@@ -423,10 +423,14 @@ export const MessageCopyTextItem = as<
}
>(({ mEvent, onClose, ...props }, ref) => {
const content = mEvent.getContent();
// Text-only: for media the `body` is the filename (or caption). We don't want
// "Copy Text" to copy a filename, so gate to textual message types.
const msgtype = content.msgtype;
const isTextual = msgtype === 'm.text' || msgtype === 'm.emote' || msgtype === 'm.notice';
const rawBody = typeof content.body === 'string' ? content.body : '';
const body = trimReplyFromBody(rawBody).trim();
if (!body) return null;
if (!isTextual || !body) return null;
const handleCopy = () => {
copyToClipboard(body);