Skip to content

Commit

Permalink
Merge #6500
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jul 6, 2023
2 parents 35d1451 + 3026c2f commit b292568
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 195 deletions.
18 changes: 17 additions & 1 deletion ts/components/conversation/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export enum GiftBadgeStates {
Opened = 'Opened',
Redeemed = 'Redeemed',
}

export type GiftBadgeType = {
expiration: number;
id: string | undefined;
Expand Down Expand Up @@ -390,6 +391,8 @@ export class Message extends React.PureComponent<Props, State> {
current: false,
};

private metadataRef: React.RefObject<HTMLDivElement> = React.createRef();

public reactionsContainerRefMerger = createRefMerger();

public expirationCheckInterval: NodeJS.Timeout | undefined;
Expand Down Expand Up @@ -823,6 +826,7 @@ export class Message extends React.PureComponent<Props, State> {
isTapToViewExpired={isTapToViewExpired}
onWidthMeasured={isInline ? this.updateMetadataWidth : undefined}
pushPanelForConversation={pushPanelForConversation}
ref={this.metadataRef}
retryMessageSend={retryMessageSend}
showEditHistoryModal={showEditHistoryModal}
status={status}
Expand Down Expand Up @@ -1779,7 +1783,7 @@ export class Message extends React.PureComponent<Props, State> {
}

return (
<div
<div // eslint-disable-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
className={classNames(
'module-message__text',
`module-message__text--${direction}`,
Expand All @@ -1790,6 +1794,18 @@ export class Message extends React.PureComponent<Props, State> {
? 'module-message__text--delete-for-everyone'
: null
)}
onClick={e => {
// Prevent metadata from being selected on triple clicks.
const clickCount = e.detail;
const range = window.getSelection()?.getRangeAt(0);
if (
clickCount === 3 &&
this.metadataRef.current &&
range?.intersectsNode(this.metadataRef.current)
) {
range.setEndBefore(this.metadataRef.current);
}
}}
onDoubleClick={(event: React.MouseEvent) => {
// Prevent double-click interefering with interactions _inside_
// the bubble.
Expand Down
Loading

0 comments on commit b292568

Please sign in to comment.