mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(web): ContextMenu unsatisfying UI behaviors (#3787)
This commit is contained in:
parent
7ad12c7f33
commit
476b735e3c
2 changed files with 28 additions and 21 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts" context="module">
|
||||
import { clickOutside } from '$lib/utils/click-outside';
|
||||
import { createContext } from '$lib/utils/context';
|
||||
|
||||
const { get: getMenuContext, set: setContext } = createContext<() => void>();
|
||||
|
|
@ -16,20 +17,22 @@
|
|||
let showContextMenu = false;
|
||||
let contextMenuPosition = { x: 0, y: 0 };
|
||||
|
||||
const handleShowMenu = ({ x, y }: MouseEvent) => {
|
||||
contextMenuPosition = { x, y };
|
||||
const handleShowMenu = ({ x }: MouseEvent) => {
|
||||
const navigationBarHeight = 75;
|
||||
contextMenuPosition = { x: x, y: navigationBarHeight };
|
||||
showContextMenu = !showContextMenu;
|
||||
};
|
||||
|
||||
setContext(() => (showContextMenu = false));
|
||||
</script>
|
||||
|
||||
<CircleIconButton {title} logo={icon} on:click={handleShowMenu} />
|
||||
|
||||
{#if showContextMenu}
|
||||
<ContextMenu {...contextMenuPosition} on:outclick={() => (showContextMenu = false)}>
|
||||
<div class="flex flex-col rounded-lg">
|
||||
<slot />
|
||||
</div>
|
||||
</ContextMenu>
|
||||
{/if}
|
||||
<div use:clickOutside on:outclick={() => (showContextMenu = false)}>
|
||||
<CircleIconButton {title} logo={icon} on:click={handleShowMenu} />
|
||||
{#if showContextMenu}
|
||||
<ContextMenu {...contextMenuPosition}>
|
||||
<div class="flex flex-col rounded-lg">
|
||||
<slot />
|
||||
</div>
|
||||
</ContextMenu>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue