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:
@@ -423,10 +423,14 @@ export const MessageCopyTextItem = as<
|
|||||||
}
|
}
|
||||||
>(({ mEvent, onClose, ...props }, ref) => {
|
>(({ mEvent, onClose, ...props }, ref) => {
|
||||||
const content = mEvent.getContent();
|
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 rawBody = typeof content.body === 'string' ? content.body : '';
|
||||||
const body = trimReplyFromBody(rawBody).trim();
|
const body = trimReplyFromBody(rawBody).trim();
|
||||||
|
|
||||||
if (!body) return null;
|
if (!isTextual || !body) return null;
|
||||||
|
|
||||||
const handleCopy = () => {
|
const handleCopy = () => {
|
||||||
copyToClipboard(body);
|
copyToClipboard(body);
|
||||||
|
|||||||
Reference in New Issue
Block a user