refactor(web): remove events from clickOutside action (#9943)

This commit is contained in:
Michel Heusschen 2024-06-02 14:20:11 +02:00 committed by GitHub
parent 5af67d159f
commit d1135db8cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 18 additions and 61 deletions

View file

@ -126,7 +126,7 @@
/>
{#if selectedMenuUser === user}
<ContextMenu {...position} on:outclick={() => (selectedMenuUser = null)}>
<ContextMenu {...position} onClose={() => (selectedMenuUser = null)}>
{#if role === AlbumUserRole.Viewer}
<MenuOption on:click={() => handleSetReadonly(user, AlbumUserRole.Editor)} text="Allow edits" />
{:else}

View file

@ -201,8 +201,7 @@
<button
type="button"
class="absolute right-6 rounded-xl items-center bg-gray-300 dark:bg-slate-100 py-3 px-6 text-left text-sm font-medium text-immich-fg hover:bg-red-300 focus:outline-none focus:ring-2 focus:ring-inset dark:text-immich-dark-bg dark:hover:bg-red-100 transition-colors"
use:clickOutside
on:outclick={() => (showDeleteReaction[index] = false)}
use:clickOutside={{ onOutclick: () => (showDeleteReaction[index] = false) }}
on:click={() => handleDeleteReaction(reaction, index)}
>
Remove
@ -254,8 +253,7 @@
<button
type="button"
class="absolute right-6 rounded-xl items-center bg-gray-300 dark:bg-slate-100 py-3 px-6 text-left text-sm font-medium text-immich-fg hover:bg-red-300 focus:outline-none focus:ring-2 focus:ring-inset dark:text-immich-dark-bg dark:hover:bg-red-100 transition-colors"
use:clickOutside
on:outclick={() => (showDeleteReaction[index] = false)}
use:clickOutside={{ onOutclick: () => (showDeleteReaction[index] = false) }}
on:click={() => handleDeleteReaction(reaction, index)}
>
Remove

View file

@ -795,7 +795,6 @@
<DeleteAssetDialog
size={1}
on:cancel={() => (isShowDeleteConfirmation = false)}
on:escape={() => (isShowDeleteConfirmation = false)}
on:confirm={() => deleteAsset()}
/>
{/if}

View file

@ -72,7 +72,7 @@
$: renderedSelectedOption = renderOption(selectedOption);
</script>
<div use:clickOutside on:outclick={handleClickOutside} on:escape={handleClickOutside}>
<div use:clickOutside={{ onOutclick: handleClickOutside, onEscape: handleClickOutside }}>
<!-- BUTTON TITLE -->
<LinkButton on:click={() => (showMenu = true)} fullwidth {title}>
<div class="flex place-items-center gap-2 text-sm">

View file

@ -87,7 +87,7 @@
{#if showContextMenu}
<Portal target="body">
<ContextMenu {...contextMenuPosition} on:outclick={() => onMenuExit()}>
<ContextMenu {...contextMenuPosition} onClose={() => onMenuExit()}>
<MenuOption on:click={() => onMenuClick('hide-person')} icon={mdiEyeOffOutline} text="Hide person" />
<MenuOption on:click={() => onMenuClick('change-name')} icon={mdiAccountEditOutline} text="Change name" />
<MenuOption

View file

@ -2,7 +2,6 @@
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
import { createEventDispatcher } from 'svelte';
import { featureFlags } from '$lib/stores/server-config.store';
import { mdiTimerSand, mdiDeleteOutline } from '@mdi/js';
import { type OnDelete, deleteAssets } from '$lib/utils/actions';
@ -14,10 +13,6 @@
const { clearSelect, getOwnedAssets } = getAssetControlContext();
const dispatch = createEventDispatcher<{
escape: void;
}>();
let isShowConfirmation = false;
let loading = false;
@ -40,11 +35,6 @@
isShowConfirmation = false;
loading = false;
};
const escape = () => {
dispatch('escape');
isShowConfirmation = false;
};
</script>
{#if menuItem}
@ -60,6 +50,5 @@
size={getOwnedAssets().size}
on:confirm={handleDelete}
on:cancel={() => (isShowConfirmation = false)}
on:escape={escape}
/>
{/if}

View file

@ -25,7 +25,7 @@
setContext(() => (showContextMenu = false));
</script>
<div use:clickOutside on:outclick={() => (showContextMenu = false)}>
<div use:clickOutside={{ onOutclick: () => (showContextMenu = false) }}>
<CircleIconButton {title} {icon} on:click={handleShowMenu} />
{#if showContextMenu}
<ContextMenu {...contextMenuPosition}>

View file

@ -8,6 +8,7 @@
export let y = 0;
export let menuElement: HTMLDivElement | undefined = undefined;
export let onClose: (() => void) | undefined = undefined;
let left: number;
let top: number;
@ -36,9 +37,7 @@
style:top="{top}px"
style:left="{left}px"
role="menu"
use:clickOutside
on:outclick
on:escape
use:clickOutside={{ onOutclick: onClose, onEscape: onClose }}
>
<div class="flex flex-col rounded-lg">
<slot />

View file

@ -49,14 +49,7 @@
on:contextmenu|preventDefault={reopenContextMenu}
role="presentation"
>
<ContextMenu
{x}
{y}
{direction}
on:outclick={closeContextMenu}
on:escape={closeContextMenu}
bind:menuElement={contextMenuElement}
>
<ContextMenu {x} {y} {direction} onClose={closeContextMenu} bind:menuElement={contextMenuElement}>
<slot />
</ContextMenu>
</section>

View file

@ -114,9 +114,10 @@
{/if}
<div
use:clickOutside
on:outclick={() => (shouldShowAccountInfoPanel = false)}
on:escape={() => (shouldShowAccountInfoPanel = false)}
use:clickOutside={{
onOutclick: () => (shouldShowAccountInfoPanel = false),
onEscape: () => (shouldShowAccountInfoPanel = false),
}}
>
<button
type="button"