You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-08 23:07:06 +02:00
fix: use pointerdown event instead
This commit is contained in:
@ -35,12 +35,12 @@ export function clickOutside(node: HTMLElement, options: Options = {}): ActionRe
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('mousedown', handleClick, true);
|
document.addEventListener('pointerdown', handleClick, true);
|
||||||
node.addEventListener('keydown', handleKey, false);
|
node.addEventListener('keydown', handleKey, false);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
destroy() {
|
destroy() {
|
||||||
document.removeEventListener('mousedown', handleClick, true);
|
document.removeEventListener('pointerdown', handleClick, true);
|
||||||
node.removeEventListener('keydown', handleKey, false);
|
node.removeEventListener('keydown', handleKey, false);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<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, {
|
||||||
@ -104,19 +105,6 @@
|
|||||||
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();
|
||||||
@ -130,7 +118,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window onresize={onResize} />
|
<svelte:window onresize={onResize} />
|
||||||
<svelte:document onclick={handleDocumentClick} />
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
use:contextMenuNavigation={{
|
use:contextMenuNavigation={{
|
||||||
@ -142,6 +129,7 @@
|
|||||||
selectedId: $selectedIdStore,
|
selectedId: $selectedIdStore,
|
||||||
selectionChanged: (id) => ($selectedIdStore = id),
|
selectionChanged: (id) => ($selectedIdStore = id),
|
||||||
}}
|
}}
|
||||||
|
use:clickOutside={{ onOutclick: closeDropdown }}
|
||||||
onresize={onResize}
|
onresize={onResize}
|
||||||
{...restProps}
|
{...restProps}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user