Disable context menu inside notifications popover

Popovers over popovers ain't easy
pull/354/merge
Lim Chee Aun 2023-12-16 14:10:33 +08:00
rodzic 86a362c619
commit 4c7c518d4d
2 zmienionych plików z 25 dodań i 15 usunięć

Wyświetl plik

@ -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" />

Wyświetl plik

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