Open user profile at around mouse anchor (#2440)
This commit is contained in:
@@ -23,6 +23,7 @@ import { UserAvatar } from '../user-avatar';
|
|||||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||||
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
||||||
import { useSpaceOptionally } from '../../hooks/useSpace';
|
import { useSpaceOptionally } from '../../hooks/useSpace';
|
||||||
|
import { getMouseEventCords } from '../../utils/dom';
|
||||||
|
|
||||||
export type EventReadersProps = {
|
export type EventReadersProps = {
|
||||||
room: Room;
|
room: Room;
|
||||||
@@ -83,7 +84,7 @@ export const EventReaders = as<'div', EventReadersProps>(
|
|||||||
room.roomId,
|
room.roomId,
|
||||||
space?.roomId,
|
space?.roomId,
|
||||||
readerId,
|
readerId,
|
||||||
event.currentTarget.getBoundingClientRect(),
|
getMouseEventCords(event.nativeEvent),
|
||||||
'Bottom'
|
'Bottom'
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import {
|
|||||||
import { useSpaceOptionally } from '../../../hooks/useSpace';
|
import { useSpaceOptionally } from '../../../hooks/useSpace';
|
||||||
import { useFlattenPowerTagMembers, useGetMemberPowerTag } from '../../../hooks/useMemberPowerTag';
|
import { useFlattenPowerTagMembers, useGetMemberPowerTag } from '../../../hooks/useMemberPowerTag';
|
||||||
import { useRoomCreators } from '../../../hooks/useRoomCreators';
|
import { useRoomCreators } from '../../../hooks/useRoomCreators';
|
||||||
|
import { getMouseEventCords } from '../../../utils/dom';
|
||||||
|
|
||||||
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||||
limit: 1000,
|
limit: 1000,
|
||||||
@@ -145,7 +146,7 @@ export function Members({ requestClose }: MembersProps) {
|
|||||||
const btn = evt.currentTarget as HTMLButtonElement;
|
const btn = evt.currentTarget as HTMLButtonElement;
|
||||||
const userId = btn.getAttribute('data-user-id');
|
const userId = btn.getAttribute('data-user-id');
|
||||||
if (userId) {
|
if (userId) {
|
||||||
openProfile(room.roomId, space?.roomId, userId, btn.getBoundingClientRect());
|
openProfile(room.roomId, space?.roomId, userId, getMouseEventCords(evt.nativeEvent));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { UserAvatar } from '../../../components/user-avatar';
|
|||||||
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||||
import { useOpenUserRoomProfile } from '../../../state/hooks/userRoomProfile';
|
import { useOpenUserRoomProfile } from '../../../state/hooks/userRoomProfile';
|
||||||
import { useSpaceOptionally } from '../../../hooks/useSpace';
|
import { useSpaceOptionally } from '../../../hooks/useSpace';
|
||||||
|
import { getMouseEventCords } from '../../../utils/dom';
|
||||||
|
|
||||||
export type ReactionViewerProps = {
|
export type ReactionViewerProps = {
|
||||||
room: Room;
|
room: Room;
|
||||||
@@ -136,7 +137,7 @@ export const ReactionViewer = as<'div', ReactionViewerProps>(
|
|||||||
room.roomId,
|
room.roomId,
|
||||||
space?.roomId,
|
space?.roomId,
|
||||||
senderId,
|
senderId,
|
||||||
event.currentTarget.getBoundingClientRect(),
|
getMouseEventCords(event.nativeEvent),
|
||||||
'Bottom'
|
'Bottom'
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -224,3 +224,10 @@ export const notificationPermission = (permission: NotificationPermission) => {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMouseEventCords = (event: MouseEvent) => ({
|
||||||
|
x: event.clientX,
|
||||||
|
y: event.clientY,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user