diff --git a/src/components/Listbox/Listbox.vue b/src/components/Listbox/Listbox.vue index 7766ed9..7a5b3e8 100644 --- a/src/components/Listbox/Listbox.vue +++ b/src/components/Listbox/Listbox.vue @@ -22,9 +22,13 @@ v-slot="{ open }" class="concrete__listbox" > + {{ selectedValue }}
-
+
{{ prefix }} + {{ selectedLabel || placeholder }} + {{ selectedLabel || placeholder }} + +
  • -
    +
    + {{ option.label }}
    - - -
  • @@ -128,7 +154,7 @@ import { useStackedValue, useInputValue, useRegisterInput, - useInputIdToOptions + useInputIdToOptions, } from '../../composables/forms.js'; import { useEventHandler } from '../../composables/events.js'; import CFormElement from '../FormElement/FormElement.vue'; @@ -264,5 +290,17 @@ const iconColorClass = computed(() => { }[props.color]; }); +function getOptionsClass() { + const el = buttonRef.value?.el; + + if (!el) return; + + const screenHeight = window.innerHeight; + const elPostionOnScreen = el.getBoundingClientRect().top; + const isOptionsBelowInput = elPostionOnScreen > screenHeight / 2; + + return isOptionsBelowInput ? 'bottom-full mb-1' : 'top-full mt-1'; +} + useRegisterInput(props, buttonRef); diff --git a/src/composables/styles.js b/src/composables/styles.js index 1e5a161..3180e55 100644 --- a/src/composables/styles.js +++ b/src/composables/styles.js @@ -33,7 +33,7 @@ const colorClassMap = { }; const layoutClasses = 'block truncate z-20 w-full border text-left' -const focusClasses = 'focus:outline-none focus:ring-1 focus:border-indigo-light focus:ring-indigo-light'; +const focusClasses = 'focus:outline-none focus:ring-1 focus:border-indigo-light ring-indigo-light'; export const inputStaticClasses = [layoutClasses, focusClasses].join(' ' + '');