diff --git a/web/src/lib/components/album-page/album-card.svelte b/web/src/lib/components/album-page/album-card.svelte index 51611616a5..713d8232f6 100644 --- a/web/src/lib/components/album-page/album-card.svelte +++ b/web/src/lib/components/album-page/album-card.svelte @@ -6,6 +6,7 @@ import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; import IconButton from '../elements/buttons/icon-button.svelte'; import type { OnClick, OnShowContextMenu } from './album-card'; + import { getContextMenuPosition } from '../../utils/context-menu'; export let album: AlbumResponseDto; export let isSharingView = false; @@ -41,12 +42,8 @@ } }; - const showAlbumContextMenu = (e: MouseEvent) => { - dispatchShowContextMenu('showalbumcontextmenu', { - x: e.clientX, - y: e.clientY, - }); - }; + const showAlbumContextMenu = (e: MouseEvent) => + dispatchShowContextMenu('showalbumcontextmenu', getContextMenuPosition(e)); onMount(async () => { imageData = (await loadHighQualityThumbnail(album.albumThumbnailAssetId)) || noThumbnailUrl; diff --git a/web/src/lib/components/album-page/share-info-modal.svelte b/web/src/lib/components/album-page/share-info-modal.svelte index 4e0ccab556..43b69fa5f9 100644 --- a/web/src/lib/components/album-page/share-info-modal.svelte +++ b/web/src/lib/components/album-page/share-info-modal.svelte @@ -10,6 +10,7 @@ import { notificationController, NotificationType } from '../shared-components/notification/notification'; import { handleError } from '../../utils/handle-error'; import ConfirmDialogue from '../shared-components/confirm-dialogue.svelte'; + import { getContextMenuPosition } from '../../utils/context-menu'; export let album: AlbumResponseDto; @@ -34,16 +35,8 @@ } }); - const showContextMenu = (user: UserResponseDto) => { - const iconButton = document.getElementById('icon-' + user.id); - - if (iconButton) { - position = { - x: iconButton.getBoundingClientRect().left, - y: iconButton.getBoundingClientRect().bottom, - }; - } - + const showContextMenu = (event: MouseEvent, user: UserResponseDto) => { + position = getContextMenuPosition(event); selectedMenuUser = user; selectedRemoveUser = null; }; @@ -105,7 +98,7 @@ {#if isOwned}
showContextMenu(user)} + on:click={(event) => showContextMenu(event, user)} logo={DotsVertical} backgroundColor="transparent" hoverColor="#e2e7e9" diff --git a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte index d7bddda630..2394964d90 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte @@ -20,6 +20,7 @@ import CircleIconButton from '../elements/buttons/circle-icon-button.svelte'; import ContextMenu from '../shared-components/context-menu/context-menu.svelte'; import MenuOption from '../shared-components/context-menu/menu-option.svelte'; + import { getContextMenuPosition } from '$lib/utils/context-menu'; export let asset: AssetResponseDto; export let showCopyButton: boolean; @@ -52,8 +53,8 @@ let contextMenuPosition = { x: 0, y: 0 }; let isShowAssetOptions = false; - const showOptionsMenu = ({ x, y }: MouseEvent) => { - contextMenuPosition = { x, y }; + const showOptionsMenu = (event: MouseEvent) => { + contextMenuPosition = getContextMenuPosition(event, 'top-right'); isShowAssetOptions = !isShowAssetOptions; }; diff --git a/web/src/lib/components/faces-page/people-card.svelte b/web/src/lib/components/faces-page/people-card.svelte index a8cff964f4..61b6565789 100644 --- a/web/src/lib/components/faces-page/people-card.svelte +++ b/web/src/lib/components/faces-page/people-card.svelte @@ -1,5 +1,6 @@