Skip to content

Commit d9b0fef

Browse files
committed
fix: allow right click on contactrow
1 parent 2d2ed2e commit d9b0fef

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

ts/components/leftpane/overlay/choose-action/ContactRow.tsx

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
import { createPortal } from 'react-dom';
2+
import { contextMenu } from 'react-contexify';
3+
import type { ReactNode } from 'react';
14
import styled, { CSSProperties } from 'styled-components';
5+
26
import { openConversationWithMessages } from '../../../../state/ducks/conversations';
37
import { Avatar, AvatarSize } from '../../../avatar/Avatar';
48
import { useShowUserDetailsCbFromConversation } from '../../../menuAndSettingsHooks/useShowUserDetailsCb';
59
import { ContactName } from '../../../conversation/ContactName/ContactName';
10+
import { MemoConversationListItemContextMenu } from '../../../menu/ConversationListItemContextMenu';
11+
import { ContextConversationProvider } from '../../../../contexts/ConvoIdContext';
12+
13+
const Portal = ({ children }: { children: ReactNode }) => {
14+
return createPortal(children, document.querySelector('.inbox.index') as Element);
15+
};
616

717
type Props = { id: string; displayName?: string; style: CSSProperties };
818

@@ -56,23 +66,35 @@ export const ContactRowBreak = (props: { char: string; key: string; style: CSSPr
5666

5767
export const ContactRow = (props: Props) => {
5868
const { id, style } = props;
69+
const triggerId = `contact-row-${id}-ctxmenu`;
5970

6071
return (
61-
<StyledRowContainer
62-
style={style}
63-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
64-
onClick={async () => openConversationWithMessages({ conversationKey: id, messageId: null })}
65-
>
66-
<AvatarItem id={id} />
67-
<ContactName
68-
data-testid="module-conversation__user__profile-name"
69-
pubkey={id}
70-
contactNameContext="contact-list-row"
71-
extraNameStyle={{
72-
color: 'var(--text-primary-color)',
73-
fontSize: 'var(--font-size-lg)',
72+
<ContextConversationProvider value={id}>
73+
<StyledRowContainer
74+
style={style}
75+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
76+
onClick={async () => openConversationWithMessages({ conversationKey: id, messageId: null })}
77+
onContextMenu={e => {
78+
contextMenu.show({
79+
id: triggerId,
80+
event: e,
81+
});
7482
}}
75-
/>
76-
</StyledRowContainer>
83+
>
84+
<AvatarItem id={id} />
85+
<ContactName
86+
data-testid="module-conversation__user__profile-name"
87+
pubkey={id}
88+
contactNameContext="contact-list-row"
89+
extraNameStyle={{
90+
color: 'var(--text-primary-color)',
91+
fontSize: 'var(--font-size-lg)',
92+
}}
93+
/>
94+
<Portal>
95+
<MemoConversationListItemContextMenu triggerId={triggerId} />
96+
</Portal>
97+
</StyledRowContainer>
98+
</ContextConversationProvider>
7799
);
78100
};

0 commit comments

Comments
 (0)