From fe1e3c2abf421a604afc745c295e58c50197f4e5 Mon Sep 17 00:00:00 2001
From: Josh Creek <8179928+jcreek@users.noreply.github.com>
Date: Sun, 12 Jul 2026 21:18:23 +0100
Subject: [PATCH] feat(*): Collapse the icon picker once an icon is chosen
---
src/lib/components/NetworkDiagram.svelte | 208 +++++++++++++++--------
1 file changed, 140 insertions(+), 68 deletions(-)
diff --git a/src/lib/components/NetworkDiagram.svelte b/src/lib/components/NetworkDiagram.svelte
index 1f99cf3..c0e4b84 100644
--- a/src/lib/components/NetworkDiagram.svelte
+++ b/src/lib/components/NetworkDiagram.svelte
@@ -73,6 +73,8 @@
let newMachineDraft = createEmptyMachine();
let newDeviceDraft = createEmptyDevice();
let iconSearch = '';
+ let iconPickerExpanded = false;
+ let lastIconPickerContext = '';
let isLoadingData = false;
let loadError: string | null = null;
@@ -330,6 +332,14 @@
? selectedVm?.iconKey ?? ''
: '';
$: selectedTargetIconPath = resolveIconPath(selectedTargetIconKey || undefined);
+ // collapse the icon picker whenever the modal target changes
+ $: {
+ const context = addModalKind ?? (selectedTarget ? JSON.stringify(selectedTarget) : '');
+ if (context !== lastIconPickerContext) {
+ lastIconPickerContext = context;
+ iconPickerExpanded = false;
+ }
+ }
$: addModalIconKey =
addModalKind === 'machine'
? newMachineDraft.iconKey ?? ''
@@ -1315,6 +1325,9 @@
if (!target) {
return;
}
+ if (normalized) {
+ iconPickerExpanded = false;
+ }
if (target.type === 'machine') {
const index = target.index;
@@ -1350,6 +1363,9 @@
function setAddModalIconKey(nextKey: string) {
const normalized = nextKey.trim();
+ if (normalized) {
+ iconPickerExpanded = false;
+ }
if (addModalKind === 'machine') {
newMachineDraft.iconKey = normalized || undefined;
return;
@@ -1724,11 +1740,13 @@
function closeSelectedTargetModal() {
selectedTarget = null;
rackNewNameTarget = null;
+ iconPickerExpanded = false;
clearIconSearch();
}
function closeAddEntityModal() {
addModalKind = null;
+ iconPickerExpanded = false;
clearIconSearch();
}
@@ -2388,44 +2406,59 @@
maxWidth="880px"
on:close={closeSelectedTargetModal}
>
-
-
- {#if selectedTargetIconPath}
+ {#if selectedTargetIconKey && !iconPickerExpanded}
+
-

+ {#if selectedTargetIconPath}
+

+ {/if}
{selectedTargetIconKey}
- {/if}
-
- Showing {Math.min(visibleIconDefinitions.length, iconResultLimit)} of {filteredIconDefinitions.length}
- matching icons
-
-
- {#each visibleIconDefinitions as icon (icon.key)}
-
- {/each}
+
- {#if filteredIconDefinitions.length === 0}
-
No icons match your search.
- {/if}
-
+ {:else}
+
+
+ {#if selectedTargetIconPath}
+
+

+
{selectedTargetIconKey}
+
+
+ {/if}
+
+ Showing {Math.min(visibleIconDefinitions.length, iconResultLimit)} of {filteredIconDefinitions.length}
+ matching icons
+
+
+ {#each visibleIconDefinitions as icon (icon.key)}
+
+ {/each}
+
+ {#if filteredIconDefinitions.length === 0}
+
No icons match your search.
+ {/if}
+
+ {/if}