From 669e9dbf4ac6b0cf9031714a2fd42d43aa9367ea Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Thu, 29 Jan 2026 17:03:25 -0600 Subject: [PATCH] fix(ui): use dynamic item height for compact mode dropdowns Account for 36px items in compact mode vs 40px in normal mode when calculating menu max-height and options container height. cc --- src/lib/components/Dropdown.svelte | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/components/Dropdown.svelte b/src/lib/components/Dropdown.svelte index 38f3b25b0..87ea21578 100644 --- a/src/lib/components/Dropdown.svelte +++ b/src/lib/components/Dropdown.svelte @@ -42,8 +42,10 @@ // Menu positioning state let menuPosition = $state<{ top?: string; bottom?: string; left?: string; right?: string }>({}); - // Item height for calculations (40px option + 0px padding = 40px) - const ITEM_HEIGHT = 40; + // Item height depends on compact mode + const ITEM_HEIGHT_NORMAL = 40; + const ITEM_HEIGHT_COMPACT = 36; + const itemHeight = $derived(compact ? ITEM_HEIGHT_COMPACT : ITEM_HEIGHT_NORMAL); const SEARCH_HEIGHT = 48; // search input height including margin const MENU_PADDING = 8; // 4px top + 4px bottom const MAX_VISIBLE_ITEMS = 4; @@ -204,8 +206,8 @@ // Calculate menu max-height based on whether search is shown const menuMaxHeight = $derived( showSearch - ? `${SEARCH_HEIGHT + (MAX_VISIBLE_ITEMS * ITEM_HEIGHT) + MENU_PADDING}px` - : `${Math.min(options.length, 8) * ITEM_HEIGHT + MENU_PADDING}px` + ? `${SEARCH_HEIGHT + (MAX_VISIBLE_ITEMS * itemHeight) + MENU_PADDING}px` + : `${Math.min(options.length, 8) * itemHeight + MENU_PADDING}px` ); @@ -244,7 +246,11 @@ /> {/if} -
+
{#each filteredOptions as option}