@@ -13,6 +13,7 @@ import Label, { LabelTypography, LabelColors } from '../Label';
1313import UserProfile from '../UserProfile' ;
1414import { classnames } from '../../utils/utils' ;
1515import useSendbird from '../../lib/Sendbird/context/hooks/useSendbird' ;
16+ import { useUserProfileContext } from '../../lib/UserProfileContext' ;
1617
1718interface MentionLabelProps {
1819 mentionTemplate : string ;
@@ -29,6 +30,7 @@ export default function MentionLabel(props: MentionLabelProps): JSX.Element {
2930 isByMe,
3031 } = props ;
3132
33+ const { disableUserProfile, renderUserProfile } = useUserProfileContext ( ) ;
3234 const mentionRef = useRef < HTMLAnchorElement > ( ) ;
3335
3436 const { state } = useSendbird ( ) ;
@@ -62,7 +64,11 @@ export default function MentionLabel(props: MentionLabelProps): JSX.Element {
6264 'sendbird-word__mention' ,
6365 amIBeingMentioned && 'sendbird-word__mention--me' ,
6466 ) }
65- onClick = { ( ) => fetchUser ( toggleDropdown ) }
67+ onClick = { ( ) => {
68+ if ( ! disableUserProfile ) {
69+ fetchUser ( toggleDropdown ) ;
70+ }
71+ } }
6672 ref = { mentionRef }
6773 data-userid = { mentionedUserId }
6874 data-nickname = { mentionedUserNickname }
@@ -76,23 +82,34 @@ export default function MentionLabel(props: MentionLabelProps): JSX.Element {
7682 </ Label >
7783 </ a >
7884 ) }
79- menuItems = { ( closeDropdown : ( ) => void ) : ReactElement => (
80- < MenuItems
81- /**
82- * parentRef: For catching location(x, y) of MenuItems
83- * parentContainRef: For toggling more options(menus & reactions)
84- */
85- parentRef = { mentionRef }
86- parentContainRef = { mentionRef }
87- closeDropdown = { closeDropdown }
88- style = { { paddingTop : '0px' , paddingBottom : '0px' } }
89- >
90- < UserProfile
91- user = { user }
92- onSuccess = { closeDropdown }
93- currentUserId = { userId }
94- />
95- </ MenuItems >
85+ menuItems = { ( closeDropdown ) => (
86+ renderUserProfile
87+ ? (
88+ renderUserProfile ( {
89+ user,
90+ close : closeDropdown ,
91+ currentUserId : userId ,
92+ avatarRef : mentionRef ,
93+ } )
94+ )
95+ : (
96+ < MenuItems
97+ /**
98+ * parentRef: For catching location(x, y) of MenuItems
99+ * parentContainRef: For toggling more options(menus & reactions)
100+ */
101+ parentRef = { mentionRef }
102+ parentContainRef = { mentionRef }
103+ closeDropdown = { closeDropdown }
104+ style = { { paddingTop : '0px' , paddingBottom : '0px' } }
105+ >
106+ < UserProfile
107+ user = { user }
108+ onSuccess = { closeDropdown }
109+ currentUserId = { userId }
110+ />
111+ </ MenuItems >
112+ )
96113 ) }
97114 />
98115 ) ;
0 commit comments