Skip to content

Commit 74ebaf6

Browse files
committed
fix(NeListbox): fix width of options list
1 parent 1fbd4e1 commit 74ebaf6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/NeListbox.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const showOptions = ref(false)
6969
const listboxRef = ref<HTMLDivElement | null>(null)
7070
const top = ref(0)
7171
const left = ref(0)
72+
const width = ref(0)
7273
const buttonRef = ref<InstanceType<typeof Listbox> | null>(null)
7374
7475
const inputValidStyle =
@@ -137,6 +138,7 @@ watch(
137138
function calculatePosition() {
138139
top.value = buttonRef.value?.$el.getBoundingClientRect().bottom + window.scrollY
139140
left.value = buttonRef.value?.$el.getBoundingClientRect().left - window.scrollX
141+
width.value = buttonRef.value?.$el.getBoundingClientRect().width || 0
140142
}
141143
142144
function onClickOutsideListbox() {
@@ -246,7 +248,7 @@ onClickOutside(listboxRef, () => onClickOutsideListbox())
246248
<ListboxOptions
247249
static
248250
:class="`absolute z-10 mt-1 max-h-60 overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-gray-500/5 focus:outline-hidden sm:text-sm dark:bg-gray-950 ${optionsPanelStyle}`"
249-
:style="[{ top: top + 'px' }, { left: left + 'px' }]"
251+
:style="[{ top: top + 'px' }, { left: left + 'px' }, { 'min-width': width + 'px' }]"
250252
>
251253
<ListboxOption
252254
v-for="option in allOptions"

0 commit comments

Comments
 (0)