diff --git a/src/lib/Combobox.svelte b/src/lib/Combobox.svelte index a191baf..279478d 100644 --- a/src/lib/Combobox.svelte +++ b/src/lib/Combobox.svelte @@ -169,13 +169,17 @@ const highlightedElement = pickerContainer.querySelector(`[data-id="${highlighted.value}"]`); if (!highlightedElement) return; - const rect = highlightedElement.getBoundingClientRect(); - const pickerRect = pickerContainer.getBoundingClientRect(); + const containerTop = pickerContainer.scrollTop; + const containerHeight = pickerContainer.clientHeight; + const elementOffsetTop = (highlightedElement as HTMLElement).offsetTop; + const elementHeight = (highlightedElement as HTMLElement).offsetHeight; - if (rect.top - 20 < pickerRect.top) { - pickerContainer.scrollTop -= pickerRect.top - rect.top + 20; - } else if (rect.bottom + 20 > pickerRect.bottom) { - pickerContainer.scrollTop += rect.bottom - pickerRect.bottom + 20; + const offset = 8; // px, adjust as needed + + if (elementOffsetTop < containerTop + offset) { + pickerContainer.scrollTop = Math.max(elementOffsetTop - offset, 0); + } else if (elementOffsetTop + elementHeight > containerTop + containerHeight - offset) { + pickerContainer.scrollTop = elementOffsetTop + elementHeight - containerHeight + offset; } }; diff --git a/src/lib/InputGroup.svelte b/src/lib/InputGroup.svelte index 9975592..721ba8d 100644 --- a/src/lib/InputGroup.svelte +++ b/src/lib/InputGroup.svelte @@ -9,4 +9,6 @@ let { class: classList, children }: Props = $props(); -
{@render children?.()}
+
+ {@render children?.()} +
diff --git a/src/lib/Label.svelte b/src/lib/Label.svelte index fe7ea4c..d0d454a 100644 --- a/src/lib/Label.svelte +++ b/src/lib/Label.svelte @@ -19,7 +19,7 @@ 'transition-fontColor block', error && !bigError ? 'mt-1 text-sm font-normal text-red-500' - : 'text-sui-text dark:text-sui-background mb-2 text-base font-medium', + : 'text-sui-text dark:text-sui-background mb-1 text-base font-medium', bigError && 'text-red-500!', classValue ]} diff --git a/src/lib/RadioGroup.svelte b/src/lib/RadioGroup.svelte index bfe3473..7277717 100644 --- a/src/lib/RadioGroup.svelte +++ b/src/lib/RadioGroup.svelte @@ -29,11 +29,11 @@ const isVert = $derived(group.orientation === 'vertical'); -
+
{#if label} {/if} -
+
{#each options as opt} {@const item = group.getItem(getValue(opt))}
(valid = e.detail.valid)} /> -
- -
+ {#if required} +
+ +
+ {/if}