Disable context menu inside notifications popover

Popovers over popovers ain't easy
This commit is contained in:
Lim Chee Aun 2023-12-16 14:10:33 +08:00
parent 86a362c619
commit 4c7c518d4d
2 changed files with 25 additions and 15 deletions

View file

@ -67,7 +67,12 @@ const contentText = {
const AVATARS_LIMIT = 50;
function Notification({ notification, instance, isStatic }) {
function Notification({
notification,
instance,
isStatic,
disableContextMenu,
}) {
const { id, status, account, report, _accounts, _statuses } = notification;
let { type } = notification;
@ -300,20 +305,24 @@ function Notification({ notification, instance, isStatic }) {
? `/${instance}/s/${actualStatusID}`
: `/s/${actualStatusID}`
}
onContextMenu={(e) => {
const post = e.target.querySelector('.status');
if (post) {
// Fire a custom event to open the context menu
if (e.metaKey) return;
e.preventDefault();
post.dispatchEvent(
new MouseEvent('contextmenu', {
clientX: e.clientX,
clientY: e.clientY,
}),
);
}
}}
onContextMenu={
!disableContextMenu
? (e) => {
const post = e.target.querySelector('.status');
if (post) {
// Fire a custom event to open the context menu
if (e.metaKey) return;
e.preventDefault();
post.dispatchEvent(
new MouseEvent('contextmenu', {
clientX: e.clientX,
clientY: e.clientY,
}),
);
}
}
: undefined
}
>
{isStatic ? (
<Status status={actualStatus} size="s" />

View file

@ -179,6 +179,7 @@ function NotificationsMenu({ anchorRef, state, onClose }) {
key={notification.id}
instance={instance}
notification={notification}
disableContextMenu
/>
))}
</>