mirror of
https://github.com/immich-app/immich
synced 2025-06-08 10:51:06 +00:00
fix(web): clicking away closes context menu (#16989)
* fix(web): clicking away closes context menu * fix: use pointerdown event instead * Revert "fix: use pointerdown event instead" This reverts commit 0d2cf4719458a1d3804c43c3877297aaf41bc107.
This commit is contained in:
parent
bcd9248b43
commit
3c87341902
@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { clickOutside } from '$lib/actions/click-outside';
|
|
||||||
import { contextMenuNavigation } from '$lib/actions/context-menu-navigation';
|
import { contextMenuNavigation } from '$lib/actions/context-menu-navigation';
|
||||||
import { shortcuts } from '$lib/actions/shortcut';
|
import { shortcuts } from '$lib/actions/shortcut';
|
||||||
import CircleIconButton, {
|
import CircleIconButton, {
|
||||||
@ -105,6 +104,19 @@
|
|||||||
closeDropdown();
|
closeDropdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDocumentClick = (event: MouseEvent) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = event.target as Node | null;
|
||||||
|
if (buttonContainer?.contains(target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDropdown();
|
||||||
|
};
|
||||||
|
|
||||||
const focusButton = () => {
|
const focusButton = () => {
|
||||||
const button = buttonContainer?.querySelector(`#${buttonId}`) as HTMLButtonElement | null;
|
const button = buttonContainer?.querySelector(`#${buttonId}`) as HTMLButtonElement | null;
|
||||||
button?.focus();
|
button?.focus();
|
||||||
@ -118,6 +130,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window onresize={onResize} />
|
<svelte:window onresize={onResize} />
|
||||||
|
<svelte:document onclick={handleDocumentClick} />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
use:contextMenuNavigation={{
|
use:contextMenuNavigation={{
|
||||||
@ -129,7 +142,6 @@
|
|||||||
selectedId: $selectedIdStore,
|
selectedId: $selectedIdStore,
|
||||||
selectionChanged: (id) => ($selectedIdStore = id),
|
selectionChanged: (id) => ($selectedIdStore = id),
|
||||||
}}
|
}}
|
||||||
use:clickOutside={{ onOutclick: closeDropdown }}
|
|
||||||
onresize={onResize}
|
onresize={onResize}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user