chore(control): prevent closing popups by clicking outside (#20)

Multiple test users closed various popups accidentally by clicking outside and rarely used the feature to close the popup.
This commit is contained in:
2026-01-19 17:40:53 +01:00
committed by GitHub
parent 99643f8029
commit 4acbc96a58
5 changed files with 9 additions and 31 deletions
@@ -18,7 +18,7 @@
} = $props(); } = $props();
function try_to_close() { function try_to_close() {
if (!content.closable || !content.open) return; if (!content.open) return;
close_function(); close_function();
} }
@@ -35,19 +35,13 @@
</script> </script>
{#if content.open} {#if content.open}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div <div
class="absolute inset-0 backdrop-blur flex justify-center items-center z-50 {className}" class="absolute inset-0 backdrop-blur flex justify-center items-center z-50 {className}"
onclick={try_to_close}
transition:fade={{ duration: 100 }} transition:fade={{ duration: 100 }}
> >
<!-- svelte-ignore a11y_no_static_element_interactions -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div <div
class="bg-stone-800 rounded-2xl min-w-[30%] max-w-[90%] max-h-[85%] flex flex-col shadow-2xl/60 overflow-hidden {content.window_class ?? class="bg-stone-800 rounded-2xl min-w-[30%] max-w-[90%] max-h-[85%] flex flex-col shadow-2xl/60 overflow-hidden {content.window_class ??
''}" ''}"
onclick={(e) => e.stopPropagation()}
> >
{#if content.title} {#if content.title}
<div class="font-bold bg-stone-700 p-1.5 flex flex-row justify-between gap-8 w-full"> <div class="font-bold bg-stone-700 p-1.5 flex flex-row justify-between gap-8 w-full">
@@ -64,16 +58,16 @@
</div> </div>
</div> </div>
<div class="flex aspect-square shrink-0"> <div class="flex aspect-square shrink-0">
{#if content.closable} <Button className="aspect-square p-1.5!" click_function={try_to_close}>
<Button className="aspect-square p-1.5!" click_function={try_to_close}> <X />
<X /> </Button>
</Button>
{/if}
</div> </div>
</div> </div>
{/if} {/if}
<div class="p-2 min-h-0 overflow-auto flex flex-col gap-2 {snippet_container_class}"> <div class="p-2 min-h-0 overflow-auto flex flex-col gap-2 {snippet_container_class}">
{@render content.snippet(content.snippet_arg)} {#if content.snippet}
{@render content.snippet(content.snippet_arg ?? '')}
{/if}
</div> </div>
</div> </div>
</div> </div>
+2 -3
View File
@@ -126,13 +126,12 @@ export type MenuOption = {
export type PopupContent = { export type PopupContent = {
open: boolean; open: boolean;
snippet: Snippet<[string]> | null; snippet: Snippet<[any]> | Snippet<[]> | Snippet | null | any;
snippet_arg?: string; snippet_arg?: any;
title?: string; title?: string;
title_class?: string; title_class?: string;
title_icon?: typeof X | null; title_icon?: typeof X | null;
window_class?: string; window_class?: string;
closable?: boolean;
}; };
export type NumberSetting = { export type NumberSetting = {
-6
View File
@@ -47,7 +47,6 @@
snippet: null, snippet: null,
title: '', title: '',
title_class: '!text-xl', title_class: '!text-xl',
closable: true
}); });
let remove_display_name = $state(''); let remove_display_name = $state('');
@@ -122,7 +121,6 @@
title_icon: Monitor, title_icon: Monitor,
title_class: '!text-xl', title_class: '!text-xl',
window_class: 'w-3xl', window_class: 'w-3xl',
closable: true
}; };
}; };
@@ -134,7 +132,6 @@
title_icon: Settings, title_icon: Settings,
title_class: '!text-xl', title_class: '!text-xl',
window_class: 'w-3xl', window_class: 'w-3xl',
closable: true
}; };
}; };
@@ -147,7 +144,6 @@
title: 'Bildschirm wirklich löschen?', title: 'Bildschirm wirklich löschen?',
title_class: 'text-red-400 !text-xl', title_class: 'text-red-400 !text-xl',
title_icon: Trash2, title_icon: Trash2,
closable: true
}; };
}; };
@@ -166,7 +162,6 @@
title: 'Bildschirm bearbeiten', title: 'Bildschirm bearbeiten',
title_icon: Monitor, title_icon: Monitor,
title_class: '!text-xl', title_class: '!text-xl',
closable: true
}; };
}; };
@@ -179,7 +174,6 @@
title: 'Über PLG MuDiCS', title: 'Über PLG MuDiCS',
title_icon: Info, title_icon: Info,
title_class: '!text-xl', title_class: '!text-xl',
closable: true
}; };
}; };
</script> </script>
@@ -45,7 +45,6 @@
open: false, open: false,
snippet: null, snippet: null,
title: '', title: '',
closable: true
}); });
function popup_close_function() { function popup_close_function() {
@@ -58,7 +57,6 @@
snippet: send_keys_popup, snippet: send_keys_popup,
title: 'Tastatur-Eingaben Senden', title: 'Tastatur-Eingaben Senden',
title_icon: Keyboard, title_icon: Keyboard,
closable: true
}; };
}; };
@@ -68,7 +66,6 @@
snippet: text_popup, snippet: text_popup,
title: 'Text Anzeigen', title: 'Text Anzeigen',
title_icon: TextAlignStart, title_icon: TextAlignStart,
closable: true,
window_class: 'size-full' window_class: 'size-full'
}; };
}; };
@@ -80,7 +77,6 @@
title: 'Webseite Anzeigen', title: 'Webseite Anzeigen',
window_class: 'w-xl', window_class: 'w-xl',
title_icon: Globe, title_icon: Globe,
closable: true
}; };
}; };
@@ -104,7 +100,6 @@
snippet: ask_shutdown_popup, snippet: ask_shutdown_popup,
title: 'Bildschirm Herunterfahren', title: 'Bildschirm Herunterfahren',
title_icon: PowerOff, title_icon: PowerOff,
closable: true
}; };
} }
@@ -67,7 +67,6 @@
open: false, open: false,
snippet: null, snippet: null,
title: '', title: '',
closable: true
}); });
let file_input: HTMLInputElement; let file_input: HTMLInputElement;
@@ -121,7 +120,6 @@
title: `${is_folder ? 'Ordner' : 'Datei'} umbenennen`, title: `${is_folder ? 'Ordner' : 'Datei'} umbenennen`,
title_icon: FolderPlus, title_icon: FolderPlus,
snippet_arg: extension, snippet_arg: extension,
closable: true
}; };
}; };
@@ -136,7 +134,6 @@
snippet: new_folder_popup, snippet: new_folder_popup,
title: 'Neuen Ordner erstellen', title: 'Neuen Ordner erstellen',
title_icon: FolderPlus, title_icon: FolderPlus,
closable: true
}; };
}; };
@@ -146,7 +143,6 @@
snippet: delete_request_popup, snippet: delete_request_popup,
title: `${$selected_file_ids.length} ${$selected_file_ids.length === 1 ? 'Objekt' : 'Objekte'} wirklich löschen?`, title: `${$selected_file_ids.length} ${$selected_file_ids.length === 1 ? 'Objekt' : 'Objekte'} wirklich löschen?`,
title_icon: Trash2, title_icon: Trash2,
closable: true
}; };
}; };