Context menu for message bubbles

This commit is contained in:
Jordan Rose 2021-06-09 15:30:05 -07:00 committed by GitHub
parent 5a3d2f7807
commit befe886a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -351,6 +351,16 @@ export class Message extends React.Component<Props, State> {
}
};
public showMenuIfNoSelection = (
event: React.MouseEvent<HTMLDivElement>
): void => {
const selection = window.getSelection();
if (selection && !selection.isCollapsed) {
return;
}
this.showMenu(event);
};
public handleImageError = (): void => {
const { id } = this.props;
window.log.info(
@ -2317,7 +2327,11 @@ export class Message extends React.Component<Props, State> {
return (
<div className="module-message__container-outer">
<div className={containerClassnames} style={containerStyles}>
<div
className={containerClassnames}
style={containerStyles}
onContextMenu={this.showMenuIfNoSelection}
>
{this.renderAuthor()}
{this.renderContents()}
</div>