On right-click link in message bubble, show menu to copy

This commit is contained in:
Jordan Rose 2021-06-14 11:49:12 -07:00 committed by GitHub
parent df0aadc8a4
commit 9a1f722545
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,13 +351,14 @@ export class Message extends React.Component<Props, State> {
} }
}; };
public showMenuIfNoSelection = ( public showContextMenu = (event: React.MouseEvent<HTMLDivElement>): void => {
event: React.MouseEvent<HTMLDivElement>
): void => {
const selection = window.getSelection(); const selection = window.getSelection();
if (selection && !selection.isCollapsed) { if (selection && !selection.isCollapsed) {
return; return;
} }
if (event.target instanceof HTMLAnchorElement) {
return;
}
this.showMenu(event); this.showMenu(event);
}; };
@ -2330,7 +2331,7 @@ export class Message extends React.Component<Props, State> {
<div <div
className={containerClassnames} className={containerClassnames}
style={containerStyles} style={containerStyles}
onContextMenu={this.showMenuIfNoSelection} onContextMenu={this.showContextMenu}
> >
{this.renderAuthor()} {this.renderAuthor()}
{this.renderContents()} {this.renderContents()}